Re: scope of generators, class variables, resulting in global na

2010-02-28 Thread dontspamleo
> > ...and really means this... > > class C: > >   x = 1 > >   def f(self,y): return T.x + y > > I don't understand what T is. Did you mean C? Yes, I meant C. Thanks. > > If so, you are wrong. self.x is not the same as .x due to > inheritance rules. Consider one example: > Thanks for the nice e

Re: scope of generators, class variables, resulting in global na

2010-02-27 Thread dontspamleo
I think a big part of the problem is that the scoping rules in Python are inconsistent because classes are a different kind of object. An example helps: This works: x = 1 def f(y): return y + x This works: def f(): x = 1 def g(y): return x + y return g(2) But this doesn't work... class

Re: scope of generators, class variables, resulting in global na

2010-02-25 Thread dontspamleo
Hi Arnaud et al, Here is the link to the bug report from which the discussion in PEP 289 was extracted: http://bugs.python.org/issue872326 It looks like they were fixing a bunch of bugs and that this discussion was one of the many in that thread. Here is another post which points to the core of

Re: scope of generators, class variables, resulting in global na

2010-02-24 Thread dontspamleo
Hi Folks, Thanks everyone for the great contributions! I understand this better now. The distinction between a shorthand for a function definition and a shorthand for a loop iteration is crucial. Also: thanks for pointing out the even the list comprehension doesn't work in py3. That was incredibl