This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Yong yang
Recipients Yong yang
Date 2009-03-31.11:27:22
SpamBayes Score 0.0003535148
Marked as misclassified No
Message-id <[email protected]>
In-reply-to
Content
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.
History
Date User Action Args
2009-03-31 11:27:25Yong yangsetrecipients: + Yong yang
2009-03-31 11:27:25Yong yangsetmessageid: <[email protected]>
2009-03-31 11:27:23Yong yanglinkissue5620 messages
2009-03-31 11:27:23Yong yangcreate