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)]

;)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to