Usefulness of the "not in" operator

candide candide at free.invalid
Sat Oct 8 06:42:58 EDT 2011


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.



More information about the Python-list mailing list