[issue7800] Attributes of type list are static

2010-01-28 Thread Chris Carter
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

[issue7800] Attributes of type list are static

2010-01-28 Thread Michael Foord
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

[issue7800] Attributes of type list are static

2010-01-28 Thread Chris Carter
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

[issue7800] Attributes of type list are static

2010-01-28 Thread Michael Foord
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

[issue7800] Attributes of type list are static

2010-01-28 Thread Chris Carter
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 ___