This is because '&' which is __and__ operator in Python is binary and
Python evaluate from left to the right.
So the first "(stm1) & (stm2)" is evaluated which result in the
construction of "And((stm1, stm2))".
After that "And((stm1, stm2)) & (stm3)" is evaluated which result in the
construction of "And((And((stm1, stm2)), stm3))" which is the expression
If you really want to have your simplified version, you must use the And
operator instead of the syntax sugar __and__:
And((stm1, stm2, stm3))
Now I anticipate the question about optimizing the __and__ operator to
append to the first And instead of encapsulate. I think it is an
optimization that will increase code complexity for a very small gain (2
Cédric Krier - B2CK SPRL
Tel: +32 472 54 46 59