Python3 exec locals - this must be a FAQ
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Feb 12 19:05:11 EST 2013
Dave Angel wrote:
>> Thanks for this hint which surprises me again since I thought
>> locals() by itself is a copy only.
>>
>
> (Thanks MRAB for your correction.)
>
> As MRAB points out, I was in error on this point. I only tested it in
> global scope. Inside a function it doesn't seem to work.
One of the two classic blunders:
- Never get involved in a land war in Asia;
- Never go against a Sicilian when death is on the line;
- Never test locals() outside of a function and extrapolate the
behaviour to inside a function!
--
Steven
More information about the Python-list
mailing list