Skip to content
Discussion options

You must be logged in to vote

Does this have any other names besides short-circuit evaluation?

Not that I'm aware of!

There's no magic in this syntax: since you're inside curly braces, it's just Python. Python has short circuit boolean operators. In addition to handling boolean values (True and False), they handle "truth-y" values (non-empty strings, non-zero integers, and anything else for which bool(value) is True) and "false-y" values (empty strings, 0, anything for which bool(value) is False).

and evaluates each value in turn. If one of them is false-y, and returns it right away (that's the short circuit). Otherwise, and returns the last evaluated value, which will be on the right.

A few examples that just use P…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sky-cake
Comment options

Answer selected by sky-cake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants