Re: Closure/method definition question for Python 2.7

2014-03-11 Thread Neil Cerutti
On 2014-03-10, Marko Rauhamaa wrote: > "Brunick, Gerard:(Constellation)" : > >> class Test(object): >> x = 10 >> >> def __init__(self): >> self.y = x >> >> t = Test() >> --- >> >> raises >> >> NameError: global name 'x' is not defined. > > In the snippet, x is neither local to __in

Re: Closure/method definition question for Python 2.7

2014-03-10 Thread Ian Kelly
On Mon, Mar 10, 2014 at 11:27 AM, Brunick, Gerard:(Constellation) wrote: > The following code: > > --- > class Test(object): > x = 10 > > def __init__(self): > self.y = x > > t = Test() > --- > > raises > > NameError: global name 'x' is not defined. > > in Python 2.7. I don't unde

Re: Closure/method definition question for Python 2.7

2014-03-10 Thread Marko Rauhamaa
"Brunick, Gerard:(Constellation)" : > class Test(object): > x = 10 > > def __init__(self): > self.y = x > > t = Test() > --- > > raises > > NameError: global name 'x' is not defined. In the snippet, x is neither local to __init__() nor global to the module. It is in the class scop