classification
Title: Magic class member variable initialization with lists
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.5
process
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 2007-11-14 19:19 by gvanrossum. This issue is now closed.

Files
File name Uploaded Description Edit
test.py 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 
behavior.

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 c.l.py why this is not a bug.
History
Date User Action Args
2007-11-14 19:19:50gvanrossumsetstatus: open -> closed
resolution: not a bug
messages: + msg57502
nosy: + gvanrossum
2007-11-14 19:10:35neoonecreate