[Python-ideas] LOAD_NAME/LOAD_GLOBAL should be use getattr()

Nick Coghlan ncoghlan at gmail.com
Tue Sep 12 23:44:23 EDT 2017


On 13 September 2017 at 02:17, Neil Schemenauer
<nas-python-ideas at arctrix.com> wrote:
> Introducing another special feature of modules to make this work is
> not the solution, IMHO.  We should make module namespaces be more
> like instance namespaces.  We already have a mechanism and it is
> getattr on objects.

One thing to keep in mind is that class instances *also* allow their
attribute access machinery to be bypassed by writing to the
instance.__dict__ directly - it's just that the instance dict may be
bypassed on lookup for data descriptors.

So that means we wouldn't need to change the way globals() works -
we'd just add the caveat that amendments made that way may be ignored
for things defined as properties.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list