Enum class
Joseph L. Casale
jcasale at activenetwerx.com
Thu Oct 15 10:38:54 EDT 2015
>>>> import enum
>>>> class M(enum.EnumMeta):
>... def __contains__(self, value):
>... print("checking", value)
>... return super().__contains__(value)
>...
>>>> class Colors(enum.Enum, metaclass=M):
>... red = 1
>... green = 2
>... blue = 3
>...
>>>> Colors.red in Colors
>checking Colors.red
>True
>
>Is that what you're asking for? If not can you give an example?
Hi Peter,
That is exactly what I was referring to, I just wondered if I overlooked some way to apply it
after the initial meta class built the instance. It appears not...
Thanks!
jlc
More information about the Python-list
mailing list