24 de septiembre de 2011

Procrastinando una atrocidad, inspirado por @ralsina :P


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:

[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()
view raw gistfile1.txt hosted with ❤ by GitHub



:)

No hay comentarios: