Thank you for raising a good point. I think we should ban referencing variables
not in the nearest outer enclosing scope until best practices regarding
closures emerge. For example:
global_var = 5
class A:
# not ok:
def foo(a:=global_var):
pass
class_var = global_var
# ok:
def foo(a:=class_var):
pass
for a in [1, 2, 3]:
# not ok:
def callback(a:=a):
pass
local = a
# ok:
def callback2(a:=local):
pass
This way, the design space is kept open.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/3VXBWI7ZSYPBEXJJASWZUF5K2L7LDPZT/
Code of Conduct: http://python.org/psf/codeofconduct/