Message251263
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. |
|
Date |
User |
Action |
Args |
2015-09-21 21:41:18 | eryksun | set | recipients:
+ eryksun, vstinner, docs@python, W deW |
2015-09-21 21:41:18 | eryksun | set | messageid: <1442871678.23.0.401485661448.issue25205@psf.upfronthosting.co.za> |
2015-09-21 21:41:18 | eryksun | link | issue25205 messages |
2015-09-21 21:41:18 | eryksun | create | |
|