[Python-ideas] PEP 505: None-aware operators
Steven D'Aprano
steve at pearwood.info
Sun Jul 22 20:51:15 EDT 2018
On Sun, Jul 22, 2018 at 11:26:15PM +1000, Chris Angelico wrote:
> You forget that the operator will *short-circuit*. It will not
> evaluate the second argument if the first argument is None. You cannot
> do this with a function, other than with a hack like a lambda
> function.
We keep running up to this issue. What if there was a language
supported, non-hackish way to officially delay evaluation of
expressions until explicitly requested?
That would allow us to write a function:
func(arg, default = delayed-expression)
and avoid new punctuation. Then the only bike-shedding will be where the
function should live and what it is called and how many arguments it
ought to take...
--
Steve
More information about the Python-ideas
mailing list