[Python-Dev] Re: PEP 667: Consistent views of namespaces

2021年8月23日 22:32:32 -0700

On Fri, Aug 20, 2021 at 04:22:56PM +0100, Mark Shannon wrote:
> Hi all,
> 
> I have submitted PEP 667 as an alternative to PEP 558.
> https://www.python.org/dev/peps/pep-0667 
Specification has a code snippet:
 def test():
 x = 1
 l()['x'] = 2
 l()['y'] = 4
 l()['z'] = 5
 y
 print(locals(), x)
https://www.python.org/dev/peps/pep-0667/#id10
Wouldn't that attempt to resolve global y, rather than local y? Unless 
there is a change to the current behaviour of the compiler, I think you 
need to fool the compiler:
 if False: y = 0 # anywhere inside the function is okay
Open Issues says:
"there would be backwards compatibility issues when locals is assigned 
to a local variable or when passed to eval."
https://www.python.org/dev/peps/pep-0667/#id24
Is that eval meant to be exec? Or both eval and exec?
-- 
Steve
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/DZMWW3ROSXSNWONOHAARPDHWLBLVLEFH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to