On Wed, May 20, 2020 at 10:19 PM James Lu <[email protected]> wrote:
>
> 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.
Another extremely plausible interpretation is that the expression is
evaluated inside the function itself.
def frobnicate(stuff, start=0, end=len(stuff)):
...
I don't think you can punt on this one. The semantics are going to
need to be well-defined from the start.
ChrisA
_______________________________________________
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/QYGQXI6ABXSVET6NCMENXCXV5OG2E67M/
Code of Conduct: http://python.org/psf/codeofconduct/