Non-identifiers in dictionary keys for **expression syntax
Ian Kelly
ian.g.kelly at gmail.com
Thu May 23 16:22:28 EDT 2013
On Thu, May 23, 2013 at 12:52 PM, Matthew Gilson <m.gilson1 at gmail.com> wrote:
> Using Cpython, we can do the following:
>
> def func(**kwargs):
> print kwargs
>
> d = {'foo bar baz':3}
>
> So that might lead us to believe that the keys of the mapping do not need to
> be valid identifiers. However, the previous function does not work with the
> following dictionary:
>
> d = {1:3}
>
> because not all the keys are strings. Is there a way to petition to get
> this more rigorously defined?
The string requirement is probably for optimization, but if the
argument is both sent and received using the ** syntax, is there a
good reason why only identifiers should be allowed?
More information about the Python-list
mailing list