On Tue, Jul 29, 2014 at 12:59:51AM +1000, Steven D'Aprano wrote:It worked in Python 2, but Python 3 added code to explicitly prevent the
> > One good reason is that people are still convinced "dict(A, **B)"
> > makes some kind of sense.
>
> Explain please. dict(A, **B) makes perfect sense to me, and it works
> perfectly too. It's a normal constructor call, using the same syntax
> as any other function or method call. Are you suggesting that it does
> not make sense?
kwargs mechanism from being abused by passing non-string keys.
Effectively, the only reason it worked was due to a Python 2.x kwargs
implementation detail.
It took me a while to come to terms with this one too, it was really
quite a nice hack. But that's all it ever was. The domain of valid keys
accepted by **kwargs should never have exceeded the range supported by
the language syntax for declaring keyword arguments.
David
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/