[Python-Dev] Tightening up the specification for locals()

Nick Coghlan ncoghlan at gmail.com
Sun May 12 16:27:22 CEST 2013


On Sun, May 12, 2013 at 11:28 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Sun, 12 May 2013 23:22:39 +1000
> Nick Coghlan <ncoghlan at gmail.com> wrote:
>> The exec case
>> corresponds to those two instances, depending on whether the single
>> namespace or dual namespace version is performed.
>
> I don't get the point. exec() *passes* a locals dictionary, but the
> compiled code itself isn't expected to use locals() as a way to access
> (let alone mutate) that dictionary.

Right, the main reason for the proposal is to lock down "locals() is
globals()" for module namespaces and "locals() is the namespace that
was returned from __prepare__ and will be passed to the metaclass
constructor" for class bodies.

The change to exec merely follows because the single argument form
corresponds to module execution and the two argument form to class
body execution.

Cheers,
Nick.


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


More information about the Python-Dev mailing list