<div dir="ltr"><div dir="ltr">Counter doesn't QUITE do the same thing as this `mdict`. But it's pretty close.<div><br></div><div>I think if .__add__() became a synonym for .update() that wouldn't break anything that currently works. But I'm probably wrong, and missing a case in my quick thought:</div><div><br></div><div><div>>>> from collections import Counter</div><div>>>> c = Counter(a=[2], b='a')</div><div>>>> c.update(c)</div><div>>>> c</div><div>Counter({'a': [2, 2], 'b': 'aa'})</div><div>>>> c2 = Counter(a=1, b=2)</div><div>>>> c2 + c2</div><div>Counter({'b': 4, 'a': 2})</div><div>>>> c2.update(c2)</div><div>>>> c2</div><div>Counter({'b': 4, 'a': 2})</div><div>>>> c + c</div><div>Traceback (most recent call last):</div><div> File "<ipython-input-18-e88785f3c342>", line 1, in <module></div><div> c + c</div><div> File "/anaconda3/lib/python3.6/collections/__init__.py", line 705, in __add__</div><div> if newcount > 0:</div><div>TypeError: '>' not supported between instances of 'list' and 'int'</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 30, 2018 at 6:54 PM Alexander Belopolsky <<a href="mailto:alexander.belopolsky@gmail.com">alexander.belopolsky@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">> In [12]: a= mdict(a=[2], b='a')<br>> In [13]: a+a<div><br></div><div>Aren't you reinventing the Counter type?</div><div><br></div><div>>>> from collections import Counter<br></div><div><div>>>> c = Counter(a=1,b=2)</div><div>>>> c + c</div><div>Counter({'b': 4, 'a': 2})</div></div></div></div></div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div></div></div></div>