not in
Michael Chermside
mcherm at destiny.com
Mon Jan 21 14:50:22 EST 2002
>> Hmm, alert, sarcasm detected :) While `not a and not b' vs. `not (a or
>> b)' is an application of language-neutral DeMorgan theorem, and `2 + 3
>> == 5' vs '3 + 2 == 5' have this icky commutative property :), `not in'
>> and `is not' are really keywords on their own. Please don't get me
>
> Sure, "not in" is not a keyword -- it's the combination of two
> keywords (into one operator), as is easy enough to check by
> counting. "is not" counts out similarly. So? Why should
> Python invent new single-keywords, when pair of keywords can
> combine readably and efficiently? I keep missing your point.
Alex, I think I understand whhat rihad is trying to get at here.
According to http://www.python.org/doc/current/ref/comparisons.html the
grammer for Python makes a special case of "not in". The expression "not
x in y" works because of the unary prefix "not" operator, the binary
infix "in" operator, and the general grammer of Python. But "x not in y"
only works because it is specifically allowed by the grammer as
mentioned above.
rihad is just asking why the Python grammer has this special case for
"not in" (and another for "is not").
rihad, the answer is quite simple. Because it matches word order in a
normal English sentence. You wouldn't ALWAYS want to match the word
order / meaning of a natural language (they sometimes have badly flawed
logic -- consider "not not" in Spanish for instance), but there are some
cases where matching the natural language aids in comprehensibility and
writability.
For some reason Guido decided that this was one of those cases. I
probably wouldn't have made the same decision, but you know what? After
using it a bit, I've decided that he was probably right. Your mileage
may vary.
Your-kilometerage-would-vary-as-well-but-thank-god-that-isn't-a-word-ly
yours,
-- Michael Chermside
More information about the Python-list
mailing list