Message90074
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? |
|
Date |
User |
Action |
Args |
2009-07-03 20:33:59 | hotdog003 | set | recipients:
+ hotdog003 |
2009-07-03 20:33:58 | hotdog003 | set | messageid: <1246653238.95.0.314927755738.issue6410@psf.upfronthosting.co.za> |
2009-07-03 20:33:57 | hotdog003 | link | issue6410 messages |
2009-07-03 20:33:56 | hotdog003 | create | |
|