not in

Neal Norwitz neal at metaslash.com
Mon Jan 21 08:30:00 EST 2002


rihad wrote:
> 
> Why does python introduce new syntax with `x not in s'? Isn't it the
> same as `not (x in s)'? Same for `is not'.

Not exactly.  'not in' and 'not is' are operators, just like 'in' and 'is'.
The byte codes that are generated are slightly different.  not (...)
generates an extra byte code.

However, 'not x in s' should equal 'x not in s'.

Use whichever is clearer to you.  I prefer x not in s, because that's
how I use it in English and how I think.

Neal



More information about the Python-list mailing list