[Tutor] and-or precedence

Krishna calvinkrishy at gmail.com
Mon Oct 10 14:28:09 CEST 2005


>>> 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


More information about the Tutor mailing list