Created
September 25, 2013 00:32
-
-
Save matiasherranz/6693320 to your computer and use it in GitHub Desktop.
Python madness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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