Re: passing context into BaseHTTPRequestHandler

2012-03-23 Thread Bernhard Herzog
(('', port), MyHandler) server.serve_forever() Bernhard -- Bernhard Herzog | ++49-541-335 08 30 | http://www.intevation.de/ Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B 18998 Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner -- http

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-02 Thread Bernhard Herzog
[EMAIL PROTECTED] writes: So, once I start the C Program from the shell, I immediately get its output in my terminal. If I start it from a subprocess in python and use python's sys.stdin/sys.stdout as the subprocess' stdout/stdin I also get it immediately. If stdout is connected to a

Re: round numbers in an array without importing Numeric or Math? - SOLVED, sort of

2006-05-17 Thread Bernhard Herzog
Paul McGuire [EMAIL PROTECTED] writes: ... or if you prefer the functional approach (using map)... roundToInt = lambda z : int(z+0.5) Topamax = map( roundToInt, map( float, map(str, Topamax) ) ) (Python also has a built-in round() function, but this returns floats, not ints - if that is

Re: list assignment

2006-02-23 Thread Bernhard Herzog
Norvell Spearman [EMAIL PROTECTED] writes: Lutz and Ascher have tuple and list assignment as separate entries in their assignment statement forms table so I was expecting there to be some difference; thanks for setting me straight. In older Python versions there was a difference between list

Re: Another newbie question

2005-12-10 Thread Bernhard Herzog
[EMAIL PROTECTED] (Alex Martelli) writes: You could make a case for a 2D coordinate class being sufficiently primitive to have immutable instances, of course (by analogy with numbers and strings) -- in that design, you would provide no mutators, and therefore neither would you provide setters

Re: sax.make_parser() segfaults

2005-12-01 Thread Bernhard Herzog
Frank Millman [EMAIL PROTECTED] writes: If I call sax.make_parser() from the interpreter or from a stand-alone program, it works fine on all machines, but in the following setup it works correctly on MSW, but segfaults on both FC4 and RH9. [...] Progress report - I have narrowed it down to

Re: Scanning a file

2005-10-28 Thread Bernhard Herzog
Jorge Godoy [EMAIL PROTECTED] writes: How about iterating through the file? You can read it line by line, two lines at a time. Pseudocode follows: line1 = read_line while line2 = read_line: line_to_check = ''.join([line1, line2]) check_for_desired_string line1 = line2

Re: Windows vs Linux

2005-10-26 Thread Bernhard Herzog
Tim Golden [EMAIL PROTECTED] writes: But as far as I can tell from my experience and from the docs -- and I'm not near a Linux box at the mo -- having used ctrl-r to recall line x in the history, you can't just down-arrow to recall x+1, x+2 etc. Or can you? You can. It works fine on

Re: C Extension - return an array of longs or pointer?

2005-10-12 Thread Bernhard Herzog
Brandon K [EMAIL PROTECTED] writes: long* result = 0; [...] result = doNumberStuff(in,x); len = sizeof(result)/sizeof(long); I don't think this will do what you appear to expect it to do. Bernhard -- Intevation GmbH http://intevation.de/

Re: C Wrapper Function, crashing Python?

2005-10-12 Thread Bernhard Herzog
Java and Swing [EMAIL PROTECTED] writes: static PyObject *wrap_doStuff(PyObject *self, PyObject *args) { [...] char *aString = 0; char *bString = 0; [...] int ok = PyArg_ParseTuple(args, sss, in, aString, bString); [...] free(aString); free(bString); aString

Re: C Wrapper Function, crashing Python?

2005-10-12 Thread Bernhard Herzog
Java and Swing [EMAIL PROTECTED] writes: thanks for the tip, however even when I do not free aString or bString, i'm still crashing at the malloc in the c function, not the wrapper. Do you have any more places where you use free incorrectly? In my experience, calling free with invalid values

Re: C Wrapper Function, crashing Python?

2005-10-12 Thread Bernhard Herzog
Java and Swing [EMAIL PROTECTED] writes: char *foo(const char *in) { char *tmp; tmp = (char *) malloc((strlen(in) * sizeof(char)) + 1); strcpy(tmp, in); ... ... free(tmp); return someValue; } Is that appropriate? I was under the impression that when you

Re: Rich Graphics?

2005-07-28 Thread Bernhard Herzog
Chris Spencer [EMAIL PROTECTED] writes: I'm trying to write a Gui in Python for manipulating rich graphical representations, similar to something like Inkscape. I've tried tkinter, wxPython, pyGtk, and while they all do traditional widgets well enough, none of them really handle anti-aliased,

Re: Can I make the Python build use an already-installed version of Expat?

2005-07-19 Thread Bernhard Herzog
Steve Juranich [EMAIL PROTECTED] writes: I'm running into problems where Python and VTK both ship with their own distribution of the Expat parser. As long as you never use the Python XML package, everything is fine. But if you try using the Python XML parser after doing an `import vtk', a

Re: Favorite non-python language trick?

2005-07-02 Thread Bernhard Herzog
Scott David Daniels [EMAIL PROTECTED] writes: Rocco Moretti wrote: Joseph Garvin wrote: I'm not aware of a language that allows it, but recently I've found myself wanting the ability to transparently replace objects I mainly look for it in the object replaces self form, but I guess you

Re: Finding startup files

2005-05-12 Thread Bernhard Herzog
Grant Edwards [EMAIL PROTECTED] writes: On 2005-05-11, jeff elkins [EMAIL PROTECTED] wrote: I'm totally new to Python (obvious,yes?) so how might argv[0] fail? argv[0] contains whatever is put there by the program that exec'ed you, and can therefore contain just about anything (or

Re: Why Python does *SLICING* the way it does??

2005-04-20 Thread Bernhard Herzog
Torsten Bronger [EMAIL PROTECTED] writes: It's interesting to muse about a language that starts at 1 for all arrays and strings, as some more or less obsolete languages do. I think this is more intuitive, since most people (including mathematicians) start counting at 1. The reason for

Re: Why Python does *SLICING* the way it does??

2005-04-20 Thread Bernhard Herzog
Torsten Bronger [EMAIL PROTECTED] writes: http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF I see only one argument there: Inclusion of the upper bound would then force the latter to be unnatural by the time the sequence has shrunk to the empty one. While this surely is unaesthetical, I

Re: exec src in {}, {} strangeness

2005-03-21 Thread Bernhard Herzog
Stefan Seefeld [EMAIL PROTECTED] writes: Is there anything wrong with 'exec source in a, b' where a and b are distinc originally empty dictionaries ? Again, my test code was class Foo: pass class Bar: foo = Foo and it appears as if 'Foo' was added to 'a', but when evaluating 'foo =

Re: A ListComp that maintains its own state

2005-02-09 Thread Bernhard Herzog
Michael Spencer [EMAIL PROTECTED] writes: So, here's factorial in one line: # state refers to list of state history - it is initialized to [1] # on any iteration, the previous state is in state[-1] # the expression also uses the trick of list.append() = None # to both update the state, and

Re: python code with indention

2005-02-08 Thread Bernhard Herzog
Nick Vargish [EMAIL PROTECTED] writes: Xah Lee [EMAIL PROTECTED] writes: is it possible to write python code without any indentation? Not if Turing-completeness is something you desire. It's possible to implement a turing machine with a single list comprehension. No indentation needed.

Re: turing machine in an LC

2005-02-08 Thread Bernhard Herzog
Jeremy Bowers [EMAIL PROTECTED] writes: On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote: Nick Vargish [EMAIL PROTECTED] writes: Xah Lee [EMAIL PROTECTED] writes: is it possible to write python code without any indentation? Not if Turing-completeness is something you desire. It's

Re: Finding user's home dir

2005-02-03 Thread Bernhard Herzog
Peter Hansen [EMAIL PROTECTED] writes: Miki Tebeka wrote: Hi all, I'm trying to write a multiplatform function that tries to return the actual user home directory. ... What's wrong with: from user import home which does about what your code does. :-) I suspect he simply didn't know

Re: Hey, get this!

2005-02-03 Thread Bernhard Herzog
Bernhard Herzog [EMAIL PROTECTED] writes: Steve Holden [EMAIL PROTECTED] writes: if package: module.__path__ = sys.path You usually should initialize a package's __path__ to an empty list. Actually, normally it's a list that contains the name of the package directory

Re: Hey, get this!

2005-02-02 Thread Bernhard Herzog
Steve Holden [EMAIL PROTECTED] writes: What *I* would like to know is: who is allowing the import of bsddb.os, thereby somehow causing the code of the os library module to be run a second time. I would guess (without actually running the code) that this part is responsible: if

Re: limited python virtual machine

2005-01-29 Thread Bernhard Herzog
[EMAIL PROTECTED] (Alex Martelli) writes: OK then -- vars(type(object)) is a dict which has [[the unbound-method equivalent of]] object.__subclasses__ at its entry for key '__subclasses__'. Scratch 'vars' in addition to 'getattr'. And 'eval' of course, or else building up the string

Re: counting items

2005-01-12 Thread Bernhard Herzog
It's me [EMAIL PROTECTED] writes: May be flatten should be build into the language somehow That shouldn't be necessary as it can easily be written in a single list comprehension: a = [[1,2,4],4,5,[2,3]] flat_a = [x for cur, rest in [[a[:1], a[1:]]] for x in cur if (not

Re: make uninstall?

2004-12-13 Thread Bernhard Herzog
Fredrik Lundh [EMAIL PROTECTED] writes: I forgot one file, btw: $ rm /usr/somewhere/bin/python $ rm /usr/somewhere/bin/python2.3 There are also pydoc and idle. Bernhard -- Intevation GmbH http://intevation.de/ Skencil