On Sun, Oct 24, 2021 at 2:52 PM David Mertz, Ph.D. <david.me...@gmail.com> wrote: > > On Sat, Oct 23, 2021, 11:46 PM David Mertz, Ph.D. >>> >>> def f(x=defer: a + b): >>> a, b = 3, 5 >>> return x >>> >>> Would this return 8, or a defer-expression? If 8, then the scope isn't >>> truly dynamic, since there's no way to keep it deferred until it moves to >>> another scope. If not 8, then I'm not sure how you'd define the scope or >>> what triggers its evaluation. > > > Oh... Keep in mind I'm proposing a strawman deliberately, but the most > natural approach to keeping an object deferred rather than evaluated is > simply to say so: > > def f(x=defer: a + b): > a, b = 3, 5 > fn2(defer: x) # look for local a, b within fn2() if needed > # ... other stuff > return x # return 8 here >
How would it know to look for a and b inside fn2's scope, instead of looking for x inside fn2's scope? ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4ESVBZZOSPOUZJIHSZCLKXPMXRAHYY2Z/ Code of Conduct: http://python.org/psf/codeofconduct/