Usefulness of the "not in" operator

Jussi Piitulainen jpiitula at ling.helsinki.fi
Thu Oct 13 04:19:16 EDT 2011


Chris Angelico writes:
> On Sun, Oct 9, 2011 at 12:07 AM, Jussi Piitulainen wrote:
> > But both negations can be avoided by modus tollens.
> >
> > "If you are able to start the car, the key is in the ignition."
> 
> But this translation implies looking at the result and ascertaining
> the state, which is less appropriate to a programming language. It's
> more like:
> 
> "If you found that you were able to start the car, the key must have
> been in the ignition."
> 
> and is thus quite inappropriate to the imperative style. A
> functional language MAY be able to use this style, but Python wants
> to have the condition and then the action.

This is not in an imperative context. The context is (generalized)
Boolean expressions, where there should not be any action, just
expressions returning values that are combined to produce a
(generalized) Boolean value.

Defined order of evaluation and short-circuiting complicate the
picture, but as a matter of style, I think there should not be any
action part in such an expression. Usually.

And "not in" is fine as far as I am concerned.



More information about the Python-list mailing list