[Python-Dev] Arbitrary non-identifier string keys when using **kwargs
Brett Cannon
brett at python.org
Fri Oct 5 17:50:30 EDT 2018
More information about the Python-Dev mailing list
Fri Oct 5 17:50:30 EDT 2018
- Previous message (by thread): [Python-Dev] Arbitrary non-identifier string keys when using **kwargs
- Next message (by thread): [Python-Dev] Arbitrary non-identifier string keys when using **kwargs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm also fine with saying that keys in **kwargs that are not proper identifiers is an implementation detail. On Thu, 4 Oct 2018 at 02:20, Serhiy Storchaka <storchaka at gmail.com> wrote: > 04.10.18 11:56, Steven D'Aprano пише: > > While keyword arguments have to be identifiers, using **kwargs allows > > arbitrary strings which aren't identifiers: > > > > py> def spam(**kwargs): > > .... print(kwargs) > > .... > > py> spam(**{"something arbitrary": 1, '\n': 2}) > > {'something arbitrary': 1, '\n': 2} > > > > > > There is some discussion on Python-Ideas on whether or not that > > behaviour ought to be considered a language feature, an accident of > > implementation, or a bug. > > > > Can we get some guidence on this please? > > This is an implementation detail. Currently CPython doesn't ensure that > keyword argument names are identifiers for performance reasons. But this > can be changed in future versions or in other implementations. > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > https://mail.python.org/mailman/options/python-dev/brett%40python.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20181005/aa9b7ff3/attachment-0001.html>
- Previous message (by thread): [Python-Dev] Arbitrary non-identifier string keys when using **kwargs
- Next message (by thread): [Python-Dev] Arbitrary non-identifier string keys when using **kwargs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list