At 12:17 AM 10/25/2007, Alan Gauld wrote:

>"Dick Moores" <[EMAIL PROTECTED]> wrote
>
> >  > Tim Peters ("Explicit is better than implicit"), isn't "if
> > lapTimeFlag ==
> >  > True" preferable?
> >
> >    if (lapTimeFlag == True) == True:
> >
> > Well, how about "Readability counts"?
>
>Thats the point.
>By calling the variable a "Flag" you are implying that
>it is a boolean that can only be True/False thus
>
>if Flag:
>
>is completely readable. There is no need for the == True part.
>
>The same is true of a predicate function. By naming it
>isXXX you imply that it is a predicate and returns True/False
>so you can write
>
>if isXXX():
>
>rather than
>
>if isXXX() == True:

Got it. Thanks, Alan.

I've also seen things like this:
 >>> a = []
 >>> if not a:
...     print 'a is empty'
...
a is empty
 >>>

Isn't this preferable?:
 >>> a = []
 >>> if a == []:
...     print 'a is empty'
...
a is empty
 >>>

Dick



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

Reply via email to