On Mon, 21 Jul 2008, Daniel Sarmiento wrote:

> What about the following function?
> 
> if x == 0:
>     return False
> return True

I don't like it, myself.  You have multiple points of exit, and, yes, you 
can see that the fallthough is only executed if the condition is not met, 
but it makes you do a double-take when reading it.

If you insist on having the conditional, this is clearer:

if x == 0:
    return False
else:
    return True

I'd rather have the condition test for truth, though:

if x != 0:
    return True
else:
    return False

But that leads to what you don't like anyway, which I think is your best 
solution:

return x != 0


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to