[Python-ideas] Delayed Execution via Keyword

Pavol Lisy pavol.lisy at gmail.com
Sun Feb 19 17:15:14 EST 2017

On 2/19/17, David Mertz <mertz at gnosis.cx> wrote:
> On Sun, Feb 19, 2017 at 10:13 AM, Joseph Hackman <josephhackman at gmail.com>
> wrote:
>> My honest preference would be that the [] is evaluated fresh each time
>> the
>> function is called.
>> def stuff(arg=delayed f()):
>> would result in f() being called every time stuff() is. This seems more
>> valuable to me than just doing it once when the function is first called.
> This doesn't make sense.  Function definition time is very different than
> function execution time.  Changing that distinction is a WAY bigger change
> than I think we should contemplate.
> Moreover, there is a completely obvious way to spell the behavior you want:
> def stuff():
>     arg = f()
>     # ... whatever ...
> This is exactly the obvious way to spell "f() is called every time stuff()
> is".

A few more complicated will be set non default value to argument.

But how to spell same behaviour in this case? ->

    def stuff(arg=delayed locals())

More information about the Python-ideas mailing list