if the else short form

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Wed Oct 6 02:45:51 CEST 2010


In message <mailman.1339.1286268545.29448.python-list at python.org>, Antoon 
Pardon wrote:

> On Tue, Oct 05, 2010 at 06:55:33PM +1300, Lawrence D'Oliveiro wrote:
>
>> In message <mailman.1232.1285927634.29448.python-list at python.org>, Antoon
>> Pardon wrote:
>> 
>> > On Wed, Sep 29, 2010 at 01:38:48PM +0200, Hrvoje Niksic wrote:
>> >
>> >> BTW adding "==True" to a boolean value is redundant and can even break
>> >> for logically true values that don't compare equal to True (such as
>> >> the number 10 or the string "foo").
>> > 
>> > But leaving it out can also break things.
>> 
>> Only in code which was incorrectly written to begin with.
> 
> Well you can always define such code as incorrectly written of course.

In this situation, I mean by “incorrectly written” code which uses non-
Boolean values as conditional expressions.



More information about the Python-list mailing list