[issue5620] The attribute's action of an object is not correct.
edmundy
report at bugs.python.org
Tue Mar 31 13:27:25 CEST 2009
New submission from edmundy <yong.sunny at 163.com>:
The following is the test code.
class C1:
myurl = []
def test(self):
url = [5,6,7]
self.myurl.extend(url)
def testv():
c = C1()
c.test()
print(c.myurl)
i = 0
while i<10 :
testv()
i = i+1
The output is :
[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]
[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, 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, 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, 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, 5, 6, 7, 5, 6, 7, 5, 6,
7, 5, 6, 7, 5, 6, 7]
The myurl of class C1 is not set to [] when a new object is created.
All objects use the same memory.
----------
components: None
messages: 84765
nosy: Yong yang
severity: normal
status: open
title: The attribute's action of an object is not correct.
type: behavior
versions: Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5620>
_______________________________________
More information about the Python-bugs-list
mailing list