Usefulness of the "not in" operator

Albert van der Horst albert at spenarnc.xs4all.nl
Sun Oct 9 12:33:37 EDT 2011


In article <qotr52nlji7.fsf at ruuvi.it.helsinki.fi>,
Jussi Piitulainen  <jpiitula at ling.helsinki.fi> wrote:
>Mel writes:
>
>> Steven D'Aprano wrote:
>>
>> > candide wrote:
>> >
>> >> 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.
>> >
>> > And "not in" is the obvious way to do it.
>> >
>> >
>> > "If the key is not in the ignition, you won't be able to start the car."
>> >
>> > "If not the key is in the ignition, you won't be able to start the car."
>> >
>> >
>> > Who like that second one speaks?
>>
>> :)
>> "If the key is not in the ignition, you will be able to start the car, not."
>
>Oh, be consistent.
>
>"If not the key is in the ignition, not you will be able to start the car."
>
>But both negations can be avoided by modus tollens.
>
>"If you are able to start the car, the key is in the ignition."

This is not normal speach. The connotation of an if sentence is
that the condition is something you have more control over
than over the result.

I sometime write
        if 0 == i :
and get complaints, as if both sides of an identity are not
equivalent.
OTOH
        if i == j :
and nobody cares it I wrote
        if j == i :

>
>And one could express "x not in s" as "(x in s) implies False" without
>making the "not" explicit if "implies" was in the language. (I know
>about <= but I also witnessed an unpleasant thread in another
>newsgroup where people insisted that <= should not be defined for
>truth values at all, and I also happen to like Python's "not in".)

Groetjes Albert


--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst




More information about the Python-list mailing list