Christophe Cavalaria schrieb: > Paul Rubin wrote: > >> André Thieme <[EMAIL PROTECTED]> writes: >>> def nif(num, pos, zero, neg): >>> if num > 0: >>> return pos >>> else: >>> if num == 0: >>> return zero >>> else: >>> return neg >> def nif(num, pos, zero, neg): >> return (neg, zero, pos)[cmp(num, 0)+1] > Since we are in one liners, let's be even smarter and do it like that : > > def nif(num, pos, zero, neg): > return (zero, pos, neg)[cmp(num, 0)]
Okay, that reduces the complexity of the Python version to that of Lisp. Now both have the same token count. André -- -- http://mail.python.org/mailman/listinfo/python-list