New submission from Michael W. <hotdog...@gmail.com>: 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? ---------- components: Interpreter Core messages: 90074 nosy: hotdog003 severity: normal status: open title: Dictionaries should support __add__ type: feature request versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6410> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com