Re: Explaining exec(globals, separate_locals)

2021-09-21 Thread Dieter Maurer
Terry Reedy wrote at 2021-9-20 12:46 -0400: >The second paragraph of the current exec entry >https://docs.python.org/3.11/library/functions.html#exec >ends with a sentence I wrote. > >"If exec gets two separate objects as globals and locals, the code will >be executed as if it were embedded in a cl

Re: Explaining exec(globals, separate_locals)

2021-09-20 Thread Eryk Sun
On 9/20/21, Terry Reedy wrote: > > "If exec gets two separate objects as globals and locals, the code will > be executed as if it were embedded in a class definition." Note that, unlike exec(), the body of a class definition can modify closure variables in nonlocal function scopes. For example:

Explaining exec(globals, separate_locals)

2021-09-20 Thread Terry Reedy
The second paragraph of the current exec entry https://docs.python.org/3.11/library/functions.html#exec ends with a sentence I wrote. "If exec gets two separate objects as globals and locals, the code will be executed as if it were embedded in a class definition." Would the following would be