[Python-ideas] dict literal allows duplicate keys

Jonathan Fine jfine2358 at gmail.com
Wed Mar 6 12:43:44 EST 2019


SUMMARY: Off-thread-topic comment on examples and words in documentation.

Inada Naoki quoted (from doc.python ref [6] in my original post):

> > If a comma-separated sequence of key/datum pairs is given, they are evaluated from left to right to define the entries of the dictionary: each key object is used as a key into the dictionary to store the corresponding datum. This means that you can specify the same key multiple times in the key/datum list, and the final dictionary’s value for that key will be the last one given.

Indeed. Although off-topic, I think

>>> {'a': 0, 'a': 1} == {'a': 1}
True

is much better than "This means that you can specify the same key
multiple times in the key/datum list, and the final dictionary’s value
for that key will be the last one given."

By the way, today I think we'd say key/value pairs. And I've read

https://www.theguardian.com/guardian-observer-style-guide-d
data takes a singular verb (like agenda), though strictly a plural;
you come across datum, the singular of data, about as often as you
hear about an agendum

Oh, and "the final dictionary's value" should I think be "the
dictionary's final value" or perhaps just "the dictionary's value"

But now we're far from the thread topic. I'm happy to join in on a
thread on improving documentation (by using simpler language and good
examples).

-- 
Jonathan


More information about the Python-ideas mailing list