[Python-ideas] dictionary constructor should not allow duplicate keys

Ethan Furman ethan at stoneleaf.us
Wed May 4 08:35:53 EDT 2016

On 05/04/2016 05:08 AM, Steven D'Aprano wrote:

> If it is worth complaining about
>      {0: None, 0: None}
> then it must also be worth complaining about:
>      {0: None, 0.0: None, int(): None, 1-1: None, len(""): None}
> etc. Otherwise, I guarantee that somebody will be pulling their hair
> out as to why Python only sometimes detects duplicate keys. Better to
> never detect them at all (so you know you have to test for duplicates
> yourself) than to give a false sense of security.

Agreed.  Either fix it all they way, or leave it alone.


More information about the Python-ideas mailing list