[docs] [issue27335] Clarify that writing to locals() inside a class body is supported
report at bugs.python.org
Thu Jun 16 13:35:01 EDT 2016
New submission from Steven D'Aprano:
The docs for locals() warn not to write to the dict returned, as it may not have the intended effect of modifying the actual variables seen by the interpreter.
But as I understanding it, using locals() inside a class body is intentionally supported:
locals()['x'] = 1
assert K.x == 1
is not just an accident of implementation, but the intended behaviour and a language guarantee.
assignee: docs at python
nosy: docs at python, steven.daprano
title: Clarify that writing to locals() inside a class body is supported
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Python tracker <report at bugs.python.org>
More information about the docs