Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41861 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2013-03-26 03:19 -0400 |
| Last post | 2013-03-26 03:19 -0400 |
| 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. Terry Reedy <tjreedy@udel.edu> - 2013-03-26 03:19 -0400
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-03-26 03:19 -0400 |
| Subject | Re: At a loss on python scoping. |
| Message-ID | <mailman.3723.1364282373.2939.python-list@python.org> |
On 3/26/2013 2:17 AM, Shiyao Ma wrote: > Hi, > suppose I have a file like this: > 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 > > a.func(3) > print(a.s) # this should print 3, also where does py store this name. > what's the underlying difference between the above example? For CPython, both the class A and the instance a have a .__dict__ attribute that stores names and values. But that is intended to be hidden and transparent for normal usage. -- Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web