Usefulness of the "not in" operator

Alain Ketterlin alain at dpt-info.u-strasbg.fr
Sat Oct 8 08:41:06 EDT 2011


candide <candide at free.invalid> writes:

> Python provides
>
>     -- the not operator, meaning logical negation
>     -- the in operator, meaning membership
>
> On the other hand, Python provides the not in operator meaning
> non-membership. However, it seems we can reformulate any "not in"
> expression using only "not" and "in" operation.

Sure, but note that you can also reformulate != using not and ==, <
using not and >=, etc. Operators like "not in" and "is not" should
really be considered single tokens, even though they seem to use "not".
And I think they are really convenient.

-- Alain.



More information about the Python-list mailing list