New submission from Chris Carter <jesdisci...@gmail.com>:

The test case at the end of this message seems to indicate that the list is 
being initialized only once for all wrapper instances.  I've tried to find 
anything about static members in Python and came up empty.  I also found no 
relevant existing bugs.

Expected output:
0 [0]
1 [1]
2 [2]
3 [3]

Actual output:
0 [0]
1 [0, 1]
2 [0, 1, 2]
3 [0, 1, 2, 3]

Test case:
i = 0
class Lister:

        list = []
        string = ""
        def __init__(self):
            global i
            self.list.append(i)
            self.string += str(i)
            i += 1
        def __str__(self):
            return "%s %s" % (self.string, self.list)

print Lister()
print Lister()
print Lister()
print Lister()

----------
components: Interpreter Core
messages: 98483
nosy: Chris.Carter
severity: normal
status: open
title: Attributes of type list are static
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7800>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to