Logic operators with "in" statement

Chris Rebert clp2 at rebertia.com
Mon Nov 16 09:46:48 EST 2009


On Mon, Nov 16, 2009 at 6:23 AM, Xavier Ho <contact at xavierho.com> wrote:
<snip>
>>>> '3' in l and 'no3' in l
> True
>
> AND operator has a higher precedence, so you don't need any brackets here, I
> think. But anyway, you have to use it like that. So that's something you'll
> have to fix first.

Er, you mean lower precedence. Higher precedence means it would bind
tighter, thus the expression would mean:
'3' in (l and 'no3') in l
which is certainly incorrect.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list