PEP 285: Adding a bool type
Chris Liechti
cliechti at gmx.net
Mon Apr 1 15:15:34 EST 2002
martin at v.loewis.de (Martin v. Loewis) wrote in
news:m3elhz8sbs.fsf at mira.informatik.hu-berlin.de:
>> I've wasted too much of my life trying to explain to people why they
>> must NOT code "if some_condition==True:" or the equivalent thereof in
>> various languages, but just "if some_condition:". The "== True"
>> appendix, useless at best, often damaging, seems one of the most
>> natural errors by newbies.
>
> That is a problem. Perhaps comparing booleans and non-booleans for
> equality should cause a warning (for that matter, perhaps even
> comparing booleans and booleans should cause that warning...)
>
> More realistically, the *parser* should emit a warning if it sees the
> name True used in such a context.
then it should warn for False too, cause 'var == False' i.e. '{} == False'
is evil too.
i think thats more of a problem for newbees than the == True redundacy in
an 'if'. they will use the form above instead of the correct 'not var'.
chris
--
Chris <cliechti at gmx.net>
More information about the Python-list
mailing list