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

Paul Moore p.f.moore at gmail.com
Thu May 5 04:22:26 EDT 2016

On 5 May 2016 at 03:38, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
> The OP mentioned (even if he didn't explicitly produce it, understandable if
> it was very long) a real-life use case where a warning/error would have
> aided debugging.
> I find this case realistic.
> Can anyone produce a single real-life use case where repeated literal keys
> needed to be accepted without a warning or error?
> Here I'm throwing down the gauntlet to those who theorise about what
> (breakable) code *might* be out in the wild, and asking them to produce just
> one real-life case.

Not literal keys no. If the proposal is *solely* that duplicate
literals are detected and objected to (I reserve judgement for now on
the question of warning vs error) then I don't think there will be
significant code breakage.

But even knowing that, the next steps are:

1. Produce a PEP (Guido has said this is a requirement)
2. Explain how this would be implemented in that PEP - because the
only implementation techniques so far mentioned in this thread fail to
restrict the check to literals.
3. Manage discussion on said PEP.

I'll await a PEP before contributing any further to the discussion.

More information about the Python-ideas mailing list