New submission from Shreyan Avigyan <[email protected]>:
Adding multiple keys of the same name to a dict should raise an exception but
instead causes a different behavior. For example consider this code,
>>> d = {"x" : "First value", "x" : "Second value", "y" : "Third value"}
One would expect a error because there two keys with the same name or that
Python will add "x" : "First value" and will skip "x" : "Second value". But the
result is opposite,
>>> d
{'x': 'Second value', 'y': 'Third value'}
Is this a bug or is this an intended behavior? (I may have missed out
information related to this in the documentation. Kindly correct me if that's
the case.)
----------
messages: 392918
nosy: shreyanavigyan
priority: normal
severity: normal
status: open
title: Adding multiple keys of the same name to a dict doesn't raise an
exception
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44033>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com