Skip to content

Instantly share code, notes, and snippets.

@wswld
Last active August 29, 2015 14:26
Show Gist options
  • Save wswld/b228e42069fbceb79960 to your computer and use it in GitHub Desktop.
Save wswld/b228e42069fbceb79960 to your computer and use it in GitHub Desktop.
Equating with logical operators in Python
>>> out = 'bar' or 'foo'
>>> out
'bar'
>>> bar = False
>>> out = bar or 'foo'
>>> out
'foo'
>>> bar = None
>>> out = bar and 'foo'
>>> print out
None
>>> out = 'foo' and 'bar' and 'tar'
>>> out
'tar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment