[issue7800] Attributes of type list are static

Michael Foord report at bugs.python.org
Fri Jan 29 01:12:57 CET 2010


Michael Foord <michael at voidspace.org.uk> added the comment:

The list in your example is a *class attribute* not an instance attribute, so yes it is only initialised once. You can still access it through the instance (self) because of Python member lookup rules.

If you want one list per instance then initialise it in __init__ instead of making it a class attribute.

In short, Python is not Java.

----------
nosy: +michael.foord
resolution:  -> invalid
status: open -> closed

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


More information about the Python-bugs-list mailing list