New submission from edmundy <yong.su...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue5620>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to