Skip to content

Instantly share code, notes, and snippets.

@matiasherranz
Created September 25, 2013 00:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save matiasherranz/6693320 to your computer and use it in GitHub Desktop.
Python madness
[matias@MacBookPro]:~$ python
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f():
... print 'f()'
...
>>> def g():
... print 'g()'
...
>>> def h():
... print 'h()'
...
>>> a = 0
>>> b = 1
>>> c = 2
>>> (f, g, h)[a or b or c]()
g()
>>> (f, g, h)[a and b or c]()
h()
>>> (f, g, h)[a and (b or c)]()
f()
>>> (f, g, h)[(a and b) or c]()
h()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment