<and> has a higher priority than <or> (as shown on the page you referenced -its "ascending priority"). Perhaps that could be clearer.
I find that brackets always make life easier in these cases (a rare statement in the Python world :-), and on a personal note I would always always comment heavily boolean operations that are not immediately obvious. it saves brain ache later on. >>> ((1 or 2) and 3) 3 However 1 or 2 and 3 is <1> if <and> is evaluated first. cheers On 10/10/05, Krishna <[EMAIL PROTECTED]> wrote: > >>> 1 or 2 and 3 > 1 > > Why does the above expression return 1? As per my understanding of > boolean operations, this is what should have happaned: > > 1 or 2 => 1 and then > 1 and 3 => 3 > > The library reference also suggests that 'or' has higher priority than 'and'. > http://docs.python.org/lib/boolean.html > > Thanks > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- -------------------------- Paul Brian m. 07875 074 534 t. 0208 352 1741 _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor