Mark Dickinson <dicki...@gmail.com> added the comment: It's documented here: https://docs.python.org/3/library/stdtypes.html#mapping-types-dict
> Numeric types used for keys obey the normal rules for numeric > comparison: if two numbers compare equal (such as 1 and 1.0) then > they can be used interchangeably to index the same dictionary entry. Since False == 0, False and 0 are interchangeable as dictionary keys. Similarly for True and 1. Note that the dictionary you created only actually has two entries: >>> dta = {False: 'false', True: 'true', 0: 'zero', 1: 'one'} >>> dta {False: 'zero', True: 'one'} Though calling out numeric types in particular in the docs does feel a little odd to me: the rule is that *any* two hashable objects that compare equal should be interchangeable for the purposes of dictionary lookup (or set membership, come to that). There's nothing particularly special about numbers in this context. ---------- nosy: +mark.dickinson _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33572> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com