[Python-ideas] add __contains__ into the "type" object

Ethan Furman ethan at stoneleaf.us
Thu Mar 2 12:08:26 EST 2017


-1.

It is already possible to specify what

   inst in cls

means by using a metaclass.  For example:

   class Color(enum.Enum):
      RED = 1
      GREEN = 2
      BLUE = 3

   some_var = Color.GREEN
   some_var in Color      # True
   some_var in enum.Enum  # False

Containment != isinstance()

--
~Ethan~


More information about the Python-ideas mailing list