New submission from Chris Carter jesdisci...@gmail.com:
The test case at the end of this message seems to indicate that the list is
being initialized only once for all wrapper instances. I've tried to find
anything about static members in Python and came up empty. I also found no
relevant
Michael Foord mich...@voidspace.org.uk added the comment:
The list in your example is a *class attribute* not an instance attribute, so
yes it is only initialised once. You can still access it through the instance
(self) because of Python member lookup rules.
If you want one list per instance
Chris Carter jesdisci...@gmail.com added the comment:
Then I must ask, why did the string attribute behave differently? I added it
to allow for that, and the behavior seems inconsistent.
--
___
Python tracker rep...@bugs.python.org
Michael Foord mich...@voidspace.org.uk added the comment:
Because strings are immutable. Your list access (self.list.append) mutates the
existing list in place.
Because strings are immutable you += is exactly equivalent to the following
code:
self.string = self.string + str(i)
The first
Chris Carter jesdisci...@gmail.com added the comment:
Ha, fun with language features. Thanks for the detailed explanation. :)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7800
___