Kirill Balunov <kirillbalu...@gmail.com> writes: > 2018-02-27 2:57 GMT+03:00 Terry Reedy <tjre...@udel.edu>: > >> The point of point 3 is that terminology and details would likely be >> different if Python were freshly designed more or less as it is today, and >> some things only make more or less sense in historical context. Learn what >> you need to know to write code that works. >> > > Thank you, I'm fairly familiar with the scope and namespace concepts in > Python 3, and they are also very well described in the "Execution model" > https://docs.python.org/3/reference/executionmodel.html#execution-model, > for this special thanks to the person who wrote it ;-) > > I started using Python with СPython 3.5 and I'm not familiar with the > Python 2 features. But since Python 2 got into our discussion, I still have > a question: > > a. Is this restriction for locals desirable in the implementation of > CPython in Python 3? > b. Or is it the result of temporary fixes for Python 2?
I think it is an implementation artefact: for efficiency reasons, local variables in a function are handled differently than "local" variables elsewhere. A side effect of the concrete implementation causes that truely local variables cannot be changed by updating the result of "locals()". The "locals" documentation tries to document the restrictions. -- https://mail.python.org/mailman/listinfo/python-list