Re:Anti-If: The missing patterns (2016)
by jstimpfle on Wednesday June 27, 2018 @12:29PM
(#17409488)
It was not about "x && y" but about the construct from the parent post as a whole. It never uses y in a boolean context, but only as a value. So I was thinking y could be anything. In python this is how it works:
'and' and 'or' in python are short-circuited as in e.g. C, but it's even more short-circuited! The "last" component is not evaluated in a boolean context. For a complete evaluation you have to use the expression in an if or while statement or apply the bool() function. I would say it's like a monad, if that helps.
[ Parent
| on HN ]
Re:Anti-If: The missing patterns (2016)
by hellofunk on Wednesday June 27, 2018 @03:03PM
(#17410840)
What you are talking about has nothing to do with short circuiting.
Re:Anti-If: The missing patterns (2016)
by jstimpfle on Wednesday June 27, 2018 @07:08PM
(#17412682)
Agreed, bad choice of words. It's only somewhat similar. Maybe "lazy" would be a better term. Whatever, man! I hope it's clear what I meant.
It’s not that you’re unclear, it’s that it is irrelevant to the discussion, as you were talking about a fairly trivial and unrelated language feature — and it is also a feature that exists in many languages, hardly unique to python.