Unexpected behaviour in MultiDict.update()

14 views
Skip to first unread message

simon

unread,
Jul 20, 2011, 11:50:58 AM7/20/11
to Pesto
Hi,

I tripped over some unexpected behaviour while using MultiDict's
update() method:

>>> from pesto.utils import MultiDict
>>> m = MultiDict({'a': 1})
>>> m
MultiDict([('a', 1)])
>>> m.update({'b': 2})
>>> m
MultiDict([('b', 2)])
>>> d = {'a': 1}
>>> d
{'a': 1}
>>> d.update({'b': 2})
>>> d
{'a': 1, 'b': 2}

MultiDict's update() deletes all existing key/value pairs and replaces
them with whatever is passed in, builtin dict's update() method adds
pairs or updates existing values. Is that intentional?

Cheers, Simon

Oliver Cope

unread,
Jul 25, 2011, 1:20:14 PM7/25/11
to python...@googlegroups.com

On 20/07/2011 17:50, simon wrote:
>
> I tripped over some unexpected behaviour while using MultiDict's
> update() method:
>

...


> MultiDict's update() deletes all existing key/value pairs and replaces
> them with whatever is passed in, builtin dict's update() method adds
> pairs or updates existing values. Is that intentional?
>

Thanks for spotting this! Sorry it took me a little while to get around
to it, but I've just pushed a new version out to the PyPI that should
fix the problem.

Cheers,

Olly.

Reply all
Reply to author
Forward
0 new messages