jfj wrote:
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?
That's because x is not assigned to anywhere in the
body of foo. The bytecode compiler optimizes away the
creation of a cell in this ca
"jfj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> def foo(x):
> y= (i for i in x)
> return y
>
> From the disassembly it seems that the generator is a code object
What is type(foo([1,2,3])) ?
> but 'x' is not a cell variable. WTF?
As I understand it, the object 'x' b
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?
Hi All--
Dan Bishop wrote:
>
> > """In Python, there are only two scopes. The global and the local.
> > The global scope is a dictionary while the local, in the case of a
> > function is extremely fast. There are no other scopes.
>
> This isn't true anymore, now that generator comprehensions h
jfj wrote:
> Max wrote:
> > Yeah, I know. It's the price we pay for forsaking variable
declarations.
> > But for java programmers like me, Py's scoping is too complicated.
> > Please explain what constitutes a block/namespace, and how to refer
to
> > variables outside of it.
>
>
> Some may disagree
Max wrote:
Yeah, I know. It's the price we pay for forsaking variable declarations.
But for java programmers like me, Py's scoping is too complicated.
Please explain what constitutes a block/namespace, and how to refer to
variables outside of it.
Some may disagree, but for me the easiest way to
On Sun, 20 Mar 2005 13:53:34 +0200, rumours say that Max
<[EMAIL PROTECTED]> might have written:
>Yeah, I know. It's the price we pay for forsaking variable declarations.
>But for java programmers like me, Py's scoping is too complicated.
>Please explain what constitutes a block/namespace, and h
Yeah, I know. It's the price we pay for forsaking variable declarations.
But for java programmers like me, Py's scoping is too complicated.
Please explain what constitutes a block/namespace, and how to refer to
variables outside of it.
--
http://mail.python.org/mailman/listinfo/python-list