Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41875 > unrolled thread
| Started by | Shiyao Ma <i@introo.me> |
|---|---|
| First post | 2013-03-26 18:35 +0800 |
| Last post | 2013-03-26 18:35 +0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: At a loss on python scoping. Shiyao Ma <i@introo.me> - 2013-03-26 18:35 +0800
| From | Shiyao Ma <i@introo.me> |
|---|---|
| Date | 2013-03-26 18:35 +0800 |
| Subject | Re: At a loss on python scoping. |
| Message-ID | <mailman.3730.1364294131.2939.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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 <rosuav@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
Back to top | Article view | comp.lang.python
csiph-web