1 > 0 == True -> False
Thibault Langlois
thibault.langlois at gmail.com
Thu Jan 30 09:46:18 EST 2014
On Thursday, January 30, 2014 2:08:58 PM UTC, Roy Smith wrote:
> In article <3dcdc95d-5e30-46d3-b558-afedf9723c7c at googlegroups.com>,
>
> Thibault Langlois <thibault.langlois at gmail.com> wrote:
>
>
>
> > You are right. I should have given some context.
>
> > I am looking at this from the perspective of the teacher that has to explain
>
> > idiosyncrasies of the language to inexperienced students.
>
> > There are two aspects in this example.
>
> > 1. the equivalence of True/False with integers 1/0 which have pro and cons.
>
> > 2. the chaining rules of operators. I agree that it may make sense in some
>
> > cases like x > y > z but when operators are mixed it leads to counter
>
> > intuitive cases as the one I pointed out.
>
> >
>
> > The recommendations to student are 1) do not assume True == 1 and do not use
>
> > operator chaining.
>
>
>
> Better than that, do what I do.
>
>
>
> 1) Assume that you don't have the full operator precedence table
>
> memorized and just parenthesize everything.
>
>
>
> 2) In cases where the expression is so simple, you couldn't possibly be
>
> wrong, see rule #1.
Agreed !
More information about the Python-list
mailing list