[New-bugs-announce] [issue2064] List of Dicts problem

Heather report at bugs.python.org
Mon Feb 11 10:39:52 CET 2008

New submission from Heather:

I have tried both Python 2.4.4 and 2.5.1 and for both, I get the
following results when running the following code:
IDLE 1.2.1      
>>> class Style:

>>> class Widget:
       styles = {}
       def setStyle(self, stylename, value):
               style = Style()
               style.stylename = stylename
               style.value = value

>>> class Container:
       widgets = []
       def addWidget(self, stylename, value):
               widget = Widget()

>>> container = Container()
>>> container.addWidget('backgroundColor','red')
>>> container.widgets[0].styles['backgroundColor'].value
>>> container.addWidget('backgroundColor','blue')
>>> container.widgets[0].styles['backgroundColor'].value
>>> container.widgets[1].styles['backgroundColor'].value
If I am doing something wrong here, please let me know. But it seems to
me to be an error that List.append() will overwrite existing entries
when using the code above - - 
Thank you,


components: None
messages: 62275
nosy: sunaluak
severity: major
status: open
title: List of Dicts problem
type: behavior
versions: Python 2.4, Python 2.5

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list