[Python-Dev] Arbitrary non-identifier string keys when using **kwargs
On 10/7/2018 1:34 PM, Chris Barker via Python-Dev wrote:
> On Fri, Oct 5, 2018 at 3:01 PM Brett Cannon <brett at python.org
> <mailto:brett at python.org>> wrote:
> I'm also fine with saying that keys in **kwargs that are not proper
> identifiers is an implementation detail.
> It's not just **kwargs -- you can also use arbitrary names with
> setattr() / getattr() :
> In : setattr(foo, "4 not an identifier", "this works")
> In : getattr(foo, "4 not an identifier")
> Out: 'this works'
When this behavior of set/getattr was discussed a decade or so ago,
Guido said not to disable it, but I believe he said it should not be
considered a language feature. There are other situations where CPython
is 'looser' than the spec.
Terry Jan Reedy