Skip to content

Instantly share code, notes, and snippets.

@skeptycal
Last active January 11, 2019 19:48
Show Gist options
  • Save skeptycal/57df94dc39a4495d7ebd9d8796280b12 to your computer and use it in GitHub Desktop.
Save skeptycal/57df94dc39a4495d7ebd9d8796280b12 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
"""
Accepts parameters of time and attention and
returns knowledge of 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')
# Originally from Dan at https://realpython.com/
# From the FREE Email Series - Python Tricks
# "If you think your friends would find this tip useful,
# please share it with them—I’d really appreciate it."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment