Python scope is too complicated
jfj
jfj at freemail.gr
Mon Mar 21 17:36:38 EST 2005
Dan Bishop wrote:
>
>>>>x = 17
>>>>sum(x for x in xrange(101))
>
> 5050
>
>>>>x
>
> 17
>
Your example with generator expressions is interesting.
Even more interesting is:
def foo(x):
y= (i for i in x)
return y
From the disassembly it seems that the generator is a code object but
'x' is not a cell variable. WTF? How do I disassemble the generator?
Must look into this....
[ list comprehensions are different because they expand to inlined
bytecode ]
jf
More information about the Python-list
mailing list