On Tue, Jul 29, 2014 at 12:59:51AM +1000, Steven D'Aprano wrote:
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?
It worked in Python 2, but Python 3 added code to explicitly prevent the 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