Acá en PyConAr Junín 2011, inspirado por unos comentarios que hizo @ralsina en una charla, surgiéronme estas atrocidades, que tenía que compartir:
This file contains 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() |
:)
No hay comentarios:
Publicar un comentario