eryksun added the comment:
The name can be any str/unicode string, including language keywords:
>>> setattr(o, 'def', 'allowed')
>>> getattr(o, 'def')
'allowed'
>>> o.def
File "<stdin>", line 1
o.def
^
SyntaxError: invalid syntax
and even an empty string:
>>> setattr(o, '', 'mu')
>>> getattr(o, '')
'mu'
This includes instances of str and unicode subclasses, at least in CPython.
----------
assignee: -> docs@python
components: +Documentation
nosy: +docs@python, eryksun
priority: normal -> low
versions: -Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue25205>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com