Skip to content

Instantly share code, notes, and snippets.

@etigui
Last active November 24, 2018 09:31
Show Gist options
  • Save etigui/6394967613b90b3e394634c465fa01ab to your computer and use it in GitHub Desktop.
Save etigui/6394967613b90b3e394634c465fa01ab to your computer and use it in GitHub Desktop.
Python different ways to test multiple flags at once in Python (PyTricks)
# Different ways to test multiple
# flags at once in Python
x, y, z = 0, 1, 0
if x == 1 or y == 1 or z == 1:
print('passed')
if 1 in (x, y, z):
print('passed')
# These only test for truthiness:
if x or y or z:
print('passed')
if any((x, y, z)):
print('passed')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment