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.

Title: Magic class member variable initialization with lists
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.5
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, neoone
Priority: normal Keywords:

Created on 2007-11-14 19:10 by neoone, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit neoone, 2007-11-14 19:10
Messages (2)
msg57500 - (view) Author: neoone (neoone) Date: 2007-11-14 19:10
Initialization of member variables with lists leads to strange 

The list object is common to each instance of that class.

File attached results in:
[] [] <__main__.Proof instance at 0x00BA7120>
['STICKYARRAY'] [] <__main__.Proof instance at 0x00BA7148>

So the initialized list a is the same in both instances.
Behaviour has been tested on 2.3 and 2.5
msg57502 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-11-14 19:19
Go ask on why this is not a bug.
Date User Action Args
2022-04-11 14:56:28adminsetgithub: 45784
2007-11-14 19:19:50gvanrossumsetstatus: open -> closed
resolution: not a bug
messages: + msg57502
nosy: + gvanrossum
2007-11-14 19:10:35neoonecreate