[issue6410] Dictionaries should support __add__

2009-07-10 Thread Terry J. Reedy
Terry J. Reedy added the comment: > what would be the result of {"a": 1, "b": 2} + {"a": 2, "b": 1}? > Should it be {"a": 1, "b": 2} or {"a": 2, "b": 1}? or {"a":[1,2], "b":[1,2]} As I remember, Guido rejected because of this ambiguity. -- nosy: +tjreedy __

[issue6410] Dictionaries should support __add__

2009-07-06 Thread Jean-Paul Calderone
Jean-Paul Calderone added the comment: Cool. I'm convinced. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue6410] Dictionaries should support __add__

2009-07-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: ISTM these examples show how little value would come from fattening-up the dict API. The examples use the copy/update pattern which is clear, explicit, and extendable to n-ary cases without incurring O(n**2) behavior. Tranforming them to a f=d+e pattern sav

[issue6410] Dictionaries should support __add__

2009-07-06 Thread Jean-Paul Calderone
Jean-Paul Calderone added the comment: FWIW, here are some use cases: http://twistedmatrix.com/trac/browser/tags/releases/twisted-8.2.0/twisted/python/context.py#L32 http://twistedmatrix.com/trac/browser/tags/releases/twisted-8.2.0/twisted/python/log.py#L270 http://twistedmatrix.com/trac/browse

[issue6410] Dictionaries should support __add__

2009-07-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, I'm -1 on the proposal because it partially overlaps the existing capability of dict.update(). To the extent it doesn't overlap, it is use case challenged (typically, it doesn't make sense to build a brand-new dictionary from two independent dictionari

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Benjamin Peterson
Benjamin Peterson added the comment: Regardless of whether this feature will be dict.merge or __add__, it needs to work its way through python-ideas first. -- resolution: -> rejected status: open -> closed ___ Python tracker

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Jean-Paul Calderone
Jean-Paul Calderone added the comment: > IIRC, Guido has previously rejected this suggestion and its variants. Got a link? It'd be nice to know what the rationale was. -- ___ Python tracker __

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: IIRC, Guido has previously rejected this suggestion and its variants. -- nosy: +rhettinger ___ Python tracker ___ ___

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Ezio Melotti
Ezio Melotti added the comment: A dict.merge() method could be added so that: >>> a = dict(x=10, y=20) >>> b = dict(y=30, z=40) >>> a.merge(b) dict(x=10, y=20, z=40) >>> b.merge(a) dict(y=30, z=40, x=10) In case of duplicate keys, the items of the second dict with the same keys will be discard

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Alexandre Vassalotti
Changes by Alexandre Vassalotti : -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Alexandre Vassalotti
Alexandre Vassalotti added the comment: Tim Gordon wrote: > __add__ is non-commutative for lists, tuples, strings etc. - perhaps > non-commutative wasn't quite what you were looking for :p. Yeah, I was not clear in my explanation. The thing is for lists, tuples, string and other ordered types

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Benjamin Peterson
Benjamin Peterson added the comment: Lists, tuples, and strings are all sequences. Adding two non-ordering mappings makes much less sense in my head than two sequences. -- nosy: +benjamin.peterson status: open -> closed ___ Python tracker

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Jean-Paul Calderone
Jean-Paul Calderone added the comment: Why so much opposition to the shorter spelling of .copy() & .update()? As Tim pointed out, lists, tuples, and strings all provide this shortcut. Why not dicts? -- nosy: +exarkun ___ Python tracker

[issue6410] Dictionaries should support __add__

2009-07-04 Thread Tim Gordon
Tim Gordon added the comment: __add__ is non-commutative for lists, tuples, strings etc. - perhaps non-commutative wasn't quite what you were looking for :p. -- nosy: +QuantumTim status: pending -> open ___ Python tracker

[issue6410] Dictionaries should support __add__

2009-07-03 Thread Alexandre Vassalotti
Alexandre Vassalotti added the comment: I am against adding __add__ to dict, since merging dictionaries is not a commutative operation. If a short syntax is desired for merging dictionaries, the just define a function. For example: def merge_dicts(*args): result = {} for x in args: re

[issue6410] Dictionaries should support __add__

2009-07-03 Thread Martin v . Löwis
Martin v. Löwis added the comment: What would you do in case of duplicate keys? -- nosy: +loewis ___ Python tracker ___ ___ Python-bug

[issue6410] Dictionaries should support __add__

2009-07-03 Thread Michael W.
New submission from Michael W. : 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) [GC