I haven't gotten to writing that into the PEP yet, but I think the rule has to be to take the scope of evaluation not the scope of definition. I know it needs to be there, and I'm just thinking about helpful examples.
Which is to say the semantics are more like `eval()` than like a lambda closure.
... and I know this is going to raise the neck hairs of many folks, because effectively I'm proposing a kind of dynamic scoping. Possibly in my defense, I think Carl's PEP 690 can do the same thing. :-)
On Tue, Jun 21, 2022, 6:27 PM Chris Angelico
What are the scoping rules for deferred objects? Do they access names where they are evaluated, or where they are defined?