Re: Read any function in runtime

2009-10-26 Thread Jack Norton
Matt McCredie wrote: Rhodri James rhodri at wildebst.demon.co.uk writes: On Fri, 23 Oct 2009 17:39:40 +0100, Matt McCredie mccredie at gmail.com wrote: joao abrantes senhor.abrantes at gmail.com writes: Hey. I want to make a program like this:print Complete the function

Re: The rap against while True: loops

2009-10-14 Thread Jack Norton
kj wrote: I'm coaching a group of biologists on basic Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with while True. Of course, that's one way to start an infinite loop, but this seems hardly a sufficient reason to avoid the

Re: Reading hex to int from a binary string

2009-10-09 Thread Jack Norton
Luc wrote: Hi all, I read data from a binary stream, so I get hex values as characters (in a string) with escaped x, like \x05\x88, instead of 0x05. I am looking for a clean way to add these two values and turn them into an integer, knowing that calling int() with base 16 throws an invalid

Re: Is there a better way to code variable number of return arguments?

2009-10-08 Thread Jack Norton
Dr. Phillip M. Feldman wrote: I currently have a function that uses a list internally but then returns the list items as separate return values as follows: if len(result)==1: return result[0] if len(result)==2: return result[0], result[1] (and so on). Is there a cleaner way to accomplish the

Retracing your steps in an interactive python env

2009-09-14 Thread Jack Norton
Hello all, I am playing around in a python shell (IPython on win32 right now actually). I am writing some code on the fly to interface to a rotary encoder (not important in this scope). Anyway, I have created a function using def, and well, I like the way it is working, however... I have