True inconsistency in Python
Terry Reedy
tjreedy at udel.edu
Tue Nov 18 18:36:14 EST 2003
"KefX" <keflimarcusx at aol.comNOSPAM> wrote in message
news:20031117201113.28795.00000484 at mb-m17.aol.com...
> >not. However long the expression is, I don't see how adding `==
true'
> >at the end makes it more clear.
>
> What if the expression is 37 lines long?
Given that
if <horrendous long expression
is *exactly equivalent* to
if True == <horrendous long expression
I see no reason for the latter and a big reason against it: adding
'True==' deceptively implies that there is some difference to justify
the extra chars. I get the feeling you actually somehow believe that
there is a difference.
Would you advocate that sums and products always start (or end) with
an analogous and explicit '0+' or '1*'? What would you think of a
style guide that mandated code like the following:
x = (0+0j) + a + b
y = 1.0 * d * e
These have been occasionally used to force result type. 'True==' also
forces, as an alternative to bool(), but if bool() is redundant, as it
is in Python for conditional expressions, so is 'True =='.
Terry J. Reedy
More information about the Python-list
mailing list