[Python-ideas] Delayed Execution via Keyword

David Mertz mertz at gnosis.cx
Sun Feb 19 14:27:38 EST 2017


On Sun, Feb 19, 2017 at 10:47 AM, Joseph Hackman <josephhackman at gmail.com>
wrote:

> Your argument has convinced me, and I now take (what i believe to be) your
>> position:
>>
>
> def stuff(arg = lazy f()):
>
> should result in a function where the default value of arg is not
> evaluated until first function call, and then the value of the expression
> is used as the default.
>

Indeed.  And in particular, f() *might not* be excuted even during that
first (or any) function call, depending on what conditional path are taken
within the function body.  That's the crucial part.  The function may have
perfectly good uses where you don't want to take the computational time, or
have the side-effects, but other uses where you need that deferred value or
action.

-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170219/1f5eb1dc/attachment-0001.html>


More information about the Python-ideas mailing list