[Python-ideas] dictionary constructor should not allow duplicate keys
Michael Selik
michael.selik at gmail.com
Wed May 4 11:57:57 EDT 2016
On Wed, May 4, 2016 at 10:59 AM Chris Angelico <rosuav at gmail.com> wrote:
> On Thu, May 5, 2016 at 12:36 AM, David Mertz <mertz at gnosis.cx> wrote:
> > The thing that nudged me to -1 is code something like the following,
> which
> > I've actually written for completely valid use-cases:
> > def code_generate(data_source, output=open('data.py','w')):
>
> This is a way of catching compile-time-detectable errors. Python has
> generally been pretty helpful with that kind of thing, even to the
> point of special-casing print-used-as-a-statement to tell you to put
> parens around it. While I fully understand that there are reasons
> against doing this (including "that's the job of linters, not the core
> language"), I do _not_ understand the apparent attitude that it's a
> fundamentally bad thing to do. Most cases where a dict display is
> used, it's intended to have unique keys.
>
You accidentally snipped out Mertz' statement that he didn't want the
interpreter to complain about "probably-bad" patterns. This implies the
distinction that linters should complain about probably-bad things while
the interpreter only complains about always-bad things.
I guess you could argue that warnings exist so that the interpreter can
complain about probably-bad things as well. If that's what you'd like, we
shouldn't call it a "compile-time-detectable error" but instead, uh, ...
hard to find the right vocabulary here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160504/6a9f3afb/attachment.html>
More information about the Python-ideas
mailing list