[issue35105] Document that CPython accepts "invalid" identifiers

Andrei Kulakov report at bugs.python.org
Fri Aug 13 18:18:37 EDT 2021


Andrei Kulakov <andrei.avk at gmail.com> added the comment:

In the last message I've said that according to __dict__ docs, anything in __dict__ is an attribute of respective obj. That's a bit too-strongly worded, the docs can be understood in the sense that anything that ends up in __dict__ via other mechanisms, such as dotted notation or setattr(), is an attribute.

Since direct manipulation of __dict__ is not prohibited, and no limits are set, AFAIK, on keys that can be used for __dict__, the more natural reading of the docs is that anything that can be directly set in __dict__ is also an attribute.

The only thing that would make a user doubt this reading is if he or she finds that getattr() cannot get non-string attrs, and going by its name, user would assume you can get any valid attrs using getattr().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35105>
_______________________________________


More information about the Python-bugs-list mailing list