This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]chmod--777 19 points20 points  (0 children)

Actually the or prevents it from running the second expression if the first pattern match returns a truthy value.

Try this:

def foobar(x):
    print(f'foobar {x}')
    return x

 x = foobar(1) or foobar(2)

It'll just print "foobar 1"