New submission from Михаил Мишакин:
First of all, i'm sorry for my English :)
I would like to union dictionaries with operator + (and +=) like this:
>>> dict(a=1, b=2) + {'a': 10, 'c': 30}
{'a': 10, 'b': 2, 'c': 30}
>>> d = dict(a=1, b=2, c={'c1': 3, 'c2': 4})
>>> d += dict(a=10, c={'c1':30})
>>> d
{'a': 10, 'b': 2, c: {'c1':30}}
Also, it gives an easy way to modify and extend the class attributes:
class Super:
params = {
'name': 'John',
'surname': 'Doe',
}
class Sub(Super):
params = Super.params + {
'surname': 'Show',
'age': 32,
}
----------
components: Interpreter Core
messages: 219867
nosy: Pix
priority: normal
severity: normal
status: open
title: Add operation "plus" for dictionaries
versions: Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue21678>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com