Sorry for my obscure description. "the name of r" , AFAIK, everything in python is just a reference. For example, a = 3, means a points to a small integer; b= [] means b points to a list somewhere in the memory. So I call r as the name of r.
To clarify my question. say I wanna look up a.r I guess the first step is to look inside a, maybe in the __dict__? As proved in my ipython, the __dict__ is empty. So, it will look up in A.__dict__ Here comes my first question, where does the scope of class A falls in when considering LEGB. On Tue, Mar 26, 2013 at 2:29 PM, Chris Angelico <ros...@gmail.com> wrote: > On Tue, Mar 26, 2013 at 5:17 PM, Shiyao Ma <i...@introo.me> wrote: > > class A: > > r = 5 > > def func(self, s): > > self.s = s > > a = A() > > print(a.r) # this should print 5, but where does py store the name of > r > > What do you mean by "the name of r"? > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > -- My gpg pubring is available via: gpg --keyserver subkeys.pgp.net--recv-keys 307CF736 More on: http://about.me/introom
-- http://mail.python.org/mailman/listinfo/python-list