[issue5620] The attribute's action of an object is not correct.
Maksim Kozyarchuk
report at bugs.python.org
Tue Mar 31 16:56:33 CEST 2009
Maksim Kozyarchuk <maksim_kozyarchuk at yahoo.com> added the comment:
AFAIK, This is expected behavior. myurl is a class attribute if you
want it to be different per instance you should re-initialize it in the
__init__ method. See below.
>>> class C1(object):
... def __init__(self):
... self.myurl = []
... def test(self):
... self.myurl.extend([5,6,7])
...
[44085 refs]
>>> def testv():
... c = C1()
... c.test()
... print(c.myurl)
...
[44108 refs]
>>> for i in range(10):
... testv()
...
[5, 6, 7]
[5, 6, 7]
[5, 6, 7]
[5, 6, 7]
[5, 6, 7]
[5, 6, 7]
[5, 6, 7]
[5, 6, 7]
[5, 6, 7]
[5, 6, 7]
[44119 refs]
----------
nosy: +Kozyarchuk
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5620>
_______________________________________
More information about the Python-bugs-list
mailing list