Message268682
| Author |
steven.daprano |
| Recipients |
docs@python, steven.daprano |
| Date |
2016年06月16日.17:35:01 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1466098501.84.0.0349098094976.issue27335@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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.
https://docs.python.org/3/library/functions.html#locals
But as I understanding it, using locals() inside a class body is intentionally supported:
class K:
locals()['x'] = 1
assert K.x == 1
is not just an accident of implementation, but the intended behaviour and a language guarantee. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年06月16日 17:35:01 | steven.daprano | set | recipients:
+ steven.daprano, docs@python |
| 2016年06月16日 17:35:01 | steven.daprano | set | messageid: <1466098501.84.0.0349098094976.issue27335@psf.upfronthosting.co.za> |
| 2016年06月16日 17:35:01 | steven.daprano | link | issue27335 messages |
| 2016年06月16日 17:35:01 | steven.daprano | create |
|