Re: Read any function in runtime

2009-10-26 Thread Jack Norton
Matt McCredie wrote: Rhodri James wildebst.demon.co.uk> writes: On Fri, 23 Oct 2009 17:39:40 +0100, Matt McCredie gmail.com> wrote: joao abrantes gmail.com> writes: Hey. I want to make a program like this:print "Complete the function f(x)="then the user would en

Re: What is Islam?-1

2009-10-21 Thread Jack Norton
omer azazi wrote: On 12 أكتوبر, 05:42, TerryP wrote: On Oct 11, 11:25 pm, omer azazi wrote: I appologise if I appear _rude_, but this is comp.lang.python -- it is for the discussion of Python and related projects that were created by men and women. A discussion about faith does not belong

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 con

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 li

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 s

Re: regex search with a space as the fist character

2009-09-17 Thread Jack Norton
Diez B. Roggisch wrote: Daniel Santos schrieb: Hello, print re.compile('u ').search(" u box2", 1) <_sre.SRE_Match object at 0x7ff1d918> print re.compile(' u ').search(" u box2", 1) None Why ? because you start searching at the offset 1, which means you try to find " u " in "u box2" - a

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 a