[Python-ideas] dict literal allows duplicate keys

Jonathan Fine jfine2358 at gmail.com
Wed Mar 6 15:48:14 EST 2019


Hi Guido

You wrote:

> Would it shut down this particular subthread if (as the language's designer, if not its BDFL) I declared that this was an explicit design decision that I made nearly 30 years ago? I should perhaps blog about the background of this decision, but it was quite a conscious one. There really is no point in thinking that this is an accident of implementation or could be changed.

Thank you for sharing this with us.

I'd be fascinated to hear about the background to this conscious
decision, and I think it would help me and others understand better
what makes Python what it is. And it might help persuade me that my
surprise at {'a': 0, 'a': 1} is misplaced, or at least exaggerated and
one-sided.

Do you want menial help writing the blog?  Perhaps if you share your
recollections, others will find the traces in the source code. For
example, I've found the first dictobject.c, dating back to 1994.
https://github.com/python/cpython/blob/956640880da20c20d5320477a0dcaf2026bd9426/Objects/dictobject.c

I'm a great fan of your Python conversation (with Biancuzzi and Warden) in
http://shop.oreilly.com/product/9780596515171.do # Masterminds of Programming

I've read this article several times, and have wished that it was more
widely available. My personal view is that putting a copy of this
article in docs.python.org would provide more benefit to the community
than you blogging on why dict literals allow duplicate keys. However,
it need not be either/or. Perhaps someone could ask the PSF to talk
with O'Reilly about getting copyright clearance to do this.

Finally, some personal remarks. I've got a long training as a pure
mathematician. For me consistency and application of simple basic
principles is important to me. And also the discovery of basic
principles.

In your interview, you say (paraphrased and without context) that most
Python code is written simply to get a job done. And that pragmatism,
rather then being hung up about theoretical concept, is the
fundamental quality in being proficient in developing with Python.

Thank you for inventing Python, and designing the language. It's a
language popular both with pure mathematicians, and also pragmatic
people who want to get things done. That's quite an achievement, which
has drawn people like me into your community.

with best regards

Jonathan


More information about the Python-ideas mailing list