tobiah a écrit :
> def foo(thing):
> 
>     if thing:
>         return thing + 1
>     else:
>         return -1
> 
> def foo(thing):
> 
>     if thing:
>         return thing + 1
>     return -1
> 
> Obviously both do the same thing.  The first is
> possibly clearer, while the second is more concise.
> 
> Comments?
> 

What about:

def foo(thing):
   if thing:
     result = thing + 1
   else:
     result = -1
   return result

and:

foo = lambda thing: thing and thing + 1 or -1
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to