[issue12233] Lists in class objects not independent

Austin Howard report at bugs.python.org
Wed Jun 1 03:39:53 CEST 2011


New submission from Austin Howard <austin1howard at gmail.com>:

When creating a class which contains elements that are lists, the lists for different instances of the class are not independent. Calling
self.mylist.append(3)
inside a class method will update the mylist variable for *all* instances of the class, not just the current instance. Attached is a script which demonstrates this behavior.

----------
components: Interpreter Core
files: python_bug.py
messages: 137410
nosy: austin1howard
priority: normal
severity: normal
status: open
title: Lists in class objects not independent
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file22218/python_bug.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12233>
_______________________________________


More information about the Python-bugs-list mailing list