Unexpected behaviour in MultiDict.update()

瀏覽次數:14 次
跳到第一則未讀訊息

simon

未讀,
2011年7月20日 上午11:50:582011/7/20
收件者: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

未讀,
2011年7月25日 下午1:20:142011/7/25
收件者: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.

回覆所有人
回覆作者
轉寄
0 則新訊息