This post PEP example for me is much cleaner and obvious, that comprehension should have access to class scope
Sorry. as I wrote in my earlier replies on the thread - restoring the Python 2 behavior for comprehension is a great win for this pep. I think there are a exhaustive checks as can be done that this change wonât break any reasonable existing code - (in the âun-reasonableâ we can put code meant to behave in an intuitive way, like the example above where a class body function was named âsetâ. ).
Sorry - if things are not clear enough by this point, then maybe the PEP should be postponed so that we can think scopes better for 3.13 - otherwise, this âsmall side effectâ seems, by all approaches, to be a big win.
The SC has approved the approach of restoring the previous class scoping behavior for 3.12 (PEP 709, for the third and (hopefully) final time ¡ Issue #192 ¡ python/steering-council ¡ GitHub). I think thatâs the right call: we get the performance benefits from PEP 709 now without changes to scoping behavior, and we have time to think about intentionally changing the behavior for 3.13. Note that the feature freeze for Python 3.12 is in less than a week.
If there is strong support for changing the scoping behavior in 3.13, we should put together a PEP that proposes that change. If the PEP is approved, it shouldnât be difficult to implement, but we should think hard about whether we really want the change. (Note that we are not restoring the Python 2 behavior. Iteration variables are still isolated.)