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

Franklin? Lee leewangzhong+python at gmail.com
Wed May 4 04:16:18 EDT 2016


On May 4, 2016 2:47 AM, "Pavol Lisy" <pavol.lisy at gmail.com> wrote:
>
> 2016-05-04 6:03 GMT+02:00, Nick Coghlan <ncoghlan at gmail.com>:
>
> > I was curious as to whether or not it was technically feasible to
> > implement this "duplicate keys" check solely for dict displays in
> > CPython without impacting other dict use cases, and it turns out it
> > should be.
>
> [...]
>
> > 1. Report a DeprecationWarning in 3.6
> > 2. Report a [RuntimeError? ValueError?] in 3.7+
>
> But what about SyntaxError instead of RuntimeError? Could it be easily
> done too?

Is it really a SyntaxError? The compiler knows what the source code means,
but it assumes that the meaning is not what you intended.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160504/8f04950e/attachment-0001.html>


More information about the Python-ideas mailing list