[issue1437] List member inside a class is shared by all instances of the class
Quentin Gallet-Gilles
report at bugs.python.org
Tue Nov 13 14:11:41 CET 2007
Quentin Gallet-Gilles added the comment:
That's the expected behavior, actually. The variables 'arr' and 's' are
static variables in the class Blah.
This is discussed in several places in the doc and the FAQ, e.g.
http://www.python.org/doc/faq/programming/#how-do-i-create-static-class-data-and-static-class-methods
What you're looking for is :
class Blah:
def __init__(self, s):
self.arr= []
self.s = s
...
----------
nosy: +quentin.gallet-gilles
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1437>
__________________________________
More information about the Python-bugs-list
mailing list