[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:
stylename=''
value=''
>>> class Widget:
styles = {}
def setStyle(self, stylename, value):
style = Style()
style.stylename = stylename
style.value = value
self.styles[stylename]=style
>>> class Container:
widgets = []
def addWidget(self, stylename, value):
widget = Widget()
widget.setStyle(stylename,value)
self.widgets.append(widget)
>>> container = Container()
>>> container.addWidget('backgroundColor','red')
>>> container.widgets[0].styles['backgroundColor'].value
'red'
>>> container.addWidget('backgroundColor','blue')
>>> container.widgets[0].styles['backgroundColor'].value
'blue'
>>> container.widgets[1].styles['backgroundColor'].value
'blue'
>>>
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,
-Heather
----------
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>
<http://bugs.python.org/issue2064>
__________________________________
More information about the New-bugs-announce
mailing list