On 9/20/21, Terry Reedy <tjre...@udel.edu> 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: >>> def f(): ... x = 'spam' ... class C: ... nonlocal x ... x = 'eggs' ... return x ... >>> f() 'eggs' -- https://mail.python.org/mailman/listinfo/python-list