iterator expression - please explain
Helmut Jarausch
jarausch at igpm.rwth-aachen.de
Mon May 24 04:30:15 EDT 2004
Erik Max Francis wrote:
> Helmut Jarausch wrote:
>
>
>>myfun(x^2 for x in xrange(10))
>
> ...
>
>>I expected the sequence 0,1,4,9,....
>>What am I missing and what's going on here?
>
>
> ^ is the bitwise xor operator. You wanted **. (Although what you wrote
> above isn't legal anyway.)
>
Many thanks for pointing out that silly mistake.
But why isn't it legal?
By the way, the corrected version (with **) works just fine (with the
CVS version of Python from the weekend or today)
Helmut.
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
More information about the Python-list
mailing list