Author hotdog003
Recipients hotdog003
Date 2009-07-03.20:33:56
SpamBayes Score 4.72428e-09
Marked as misclassified No
Message-id <1246653238.95.0.314927755738.issue6410@psf.upfronthosting.co.za>
In-reply-to
Content
Summary:
Dictionaries should support being added to other dictionaries instead of
using update(). This should be a relatively easy fix and would make the
language more pythonic.

How to reproduce:
$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> {1: 2, 3: 4} + {5: 6, 7: 8}

What happens:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'

What should happen:
{1: 2, 3: 4, 5: 6, 7: 8}

Temporary workaround:
>>> a = {1: 2, 3: 4}
>>> b = {5: 6, 7: 8}
>>> c = a.copy()
>>> c.update(b)
>>> print c
{1: 2, 3: 4, 5: 6, 7: 8}
This is undesirable because it is not very compact and hard to read. Why
should any language take five lines of code to merge only two dictionaries?
History
Date User Action Args
2009-07-03 20:33:59hotdog003setrecipients: + hotdog003
2009-07-03 20:33:58hotdog003setmessageid: <1246653238.95.0.314927755738.issue6410@psf.upfronthosting.co.za>
2009-07-03 20:33:57hotdog003linkissue6410 messages
2009-07-03 20:33:56hotdog003create