Usefulness of the "not in" operator
Jon Clements
joncle at googlemail.com
Sat Oct 8 06:50:00 EDT 2011
On Oct 8, 11:42 am, candide <cand... at free.invalid> wrote:
> 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. For instance
>
> >>> 'th' not in "python"
> False
>
> >>> not ('th' in "python")
> False
> >>>
>
> So what is the usefulness of the "not in" operator ? Recall what Zen of
> Python tells
>
> There should be one-- and preferably only one --obvious way to do it.
You would seriously prefer the later?
Guess I'll have to start writing stuff like:
10 - 5 as 10 + -5 (as obviously the - is redundant as an operation),
and 10 / 2 as int(10 * .5) or something, who needs a divide!?
Jokely yours,
Jon.
More information about the Python-list
mailing list