[Python-ideas] dictionary constructor should not allow duplicate keys
Random832
random832 at fastmail.com
Wed May 4 00:18:59 EDT 2016
On Tue, May 3, 2016, at 23:31, Chris Angelico wrote:
> Duplicate keys in dict display
> is more similar to duplicate keyword arguments in a function call than
> to reassignment.
To play devil's advocate for a minute here...
Why *don't* we allow duplicate keyword arguments in a function call,
anyway? CALL_FUNCTION doesn't seem to actually care, if I create this
situation by monkey-patching the calling function's consts to get
duplicate keywords. All the arguments that have been raised here for
*allowing* duplicate keyword arguments seem to apply just as well to
f(**{'a': 1}, **{'a': 2}) [where 'a' may not be the only key present and
they may not be literal^Wdisplays], yet that is prohibited. Why not
remove that check, too?
If we can blithely pass the same constant key twice to BUILD_MAP, why
*shouldn't* we be able to do the same to CALL_FUNCTION? Any argument
against the latter applies equally to the former, as far as I can see.
More information about the Python-ideas
mailing list