Coding style and else statements

Jorge Vargas jorge.vargas at gmail.com
Mon Aug 28 17:56:24 EDT 2006


On 8/28/06, tobiah <st at tobiah.org> wrote:
> 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?
if there is nothing the else will check why put it there?
>
> --
> Posted via a free Usenet account from http://www.teranews.com
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list