Next / Previous / Contents / TCC Help System / NM Tech homepage

26.3.7. __contains__(): The “in” and “not in” operators

This special method defines how instances of a class behave when they appear as the right-hand operand of Python's “in” and “not in” operators.

Here is the calling sequence:

    def __contains__(self, x):

The method returns True if x is considered to be in self, False otherwise.