[issue2064] List of Dicts problem

Christian Heimes report at bugs.python.org
Mon Feb 11 11:59:43 CET 2008


Christian Heimes added the comment:

It's a classic problem for new Python developers. You have declared a
mutable object at class level. styles and widgets are the same object
for all instances of Widget and Container. You have to create them
inside the initializer.

Try

class Widget:
    def __init__(self):
        self.styles = {}

Next time please use the mailing list instead of the bug tracker to get
help.

----------
nosy: +tiran
resolution:  -> invalid
status: open -> closed

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2064>
__________________________________


More information about the Python-bugs-list mailing list