Steven D'Aprano writes:
> Suppose Python had a mechanism to delay the evaluation of expressions
> until needed. What would you use it for?
Delayed evaluation is some form of "lazy evaluation": evaluate an
expression (only) at the time, it is needed (maybe
I could easily see using all of the examples; I run into this pretty regularly.
What about something like the following (which, honestly is really a
combination of other examples).
If I have a function that has multiple parameters, each of which might be
expensive, but it might break out
Suppose Python had a mechanism to delay the evaluation of expressions
until needed. What would you use it for?
Python already does this on an ad hoc basis. For example, the "and" and
"or" operators are special:
and
If the expression on the left is falsey, the expression on the right is