__init__ & attributes clarification
aleax at aleax.it
Sun Feb 2 23:36:26 CET 2003
> This is unusual in my experience... So, if an object writes to a member
> with the same name as a class member, does it change that class member for
> the class, all instances of the class, all future instances, or just self?
"writes to" is ambiguous -- can mean "rebind" or "modify" (e.g.,
call the .append method on a list object) -- two totally different
cases, of course.
Assuming you do mean rebind:
foo = 23
self.foo = 34
X.foo = 45
is there any possible doubt left about which method rebinds
the attribute of class X, and which one instead rebinds a
(per-instance) attribute of self...?
More information about the Python-list