how to read stdout without blocking

2009-12-22 Thread Hamish McKenzie
I need to run a cmd line app from python whose run time can vary from a fraction of a second to minutes. I need to be able to tell whether the process is still waiting, or whether it has stalled - and this is farily easily done by keeping an eye on whether its writing to stdout or not. The

getting caller

2009-02-12 Thread Hamish McKenzie
so I'm trying to wrap some functionality around execfile but don't want to modify the way it works. specifically when you call execfile, it automatically grabs globals and locals from the frame the execfile exists in. so if I wrap execfile in a function, I need a way to reliably get at the

RE: type conversion

2009-01-02 Thread Hamish McKenzie
12:12 PM To: python-list@python.org Subject: Re: type conversion On Jan 2, 1:46 pm, Robert Kern robert.k...@gmail.com wrote: r wrote: On Jan 1, 4:40 pm, Robert Kern robert.k...@gmail.com wrote: Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety

RE: type conversion

2009-01-01 Thread Hamish McKenzie
You could also use a dict with type:method key/value pairings. This is closer to a switch/case than an if...elif chain is. of course, that's a great idea... thanks. -- http://mail.python.org/mailman/listinfo/python-list

type conversion

2008-12-31 Thread Hamish McKenzie
sometimes I want to be able to initialize an instance with a variety of different data types. as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16 floats, another matrix or a quaternion. is there any other way to do it other than putting case

python bug when subclassing list?

2008-11-06 Thread Hamish McKenzie
I want to write a Vector class and it makes the most sense to just subclass list. I also want to be able to instantiate a vector using either: Vector( 1, 2, 3 ) OR Vector( [1, 2, 3] ) so I have this: class Vector(list): def __new__( cls, *a ): try:

python bug when subclassing list?

2008-11-06 Thread Hamish McKenzie
I want to write a Vector class and it makes the most sense to just subclass list. I also want to be able to instantiate a vector using either: Vector( 1, 2, 3 ) OR Vector( [1, 2, 3] ) so I have this: class Vector(list): def __new__( cls, *a ): try: print a

inheritance question...

2008-06-20 Thread Hamish McKenzie
I have this class: class Vector(object): TOL = 1e-5 def __eq__( self, other, tolerance=TOL ): print tolerance shortened for clarity obviously. so I want to subclass this class like so: class BigVector(Vector) TOL = 100 for example if I was working with large

str class inheritance prob?

2008-04-16 Thread Hamish McKenzie
so I'm trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while