Hi

I am looking the relationship between some classes
from the enum module

from enum import EnumMeta, Enum

class Color(Enum):
             pass

type(EnumMeta)
<class 'type'>
EnumMeta.__bases__
(<class 'type'>,)


so EnumMeta is a metaclass, it is an instance of type
and inherit from type too.

type(Enum)
<class 'enum.EnumMeta'>
Enum.__bases__
(<class 'object'>,)

so Enum is an instance of EnumMeta
and Enum inherit from object

type(Color)
<class 'enum.EnumMeta'>
Color.__bases__
(<enum 'Enum'>,)

so Color is an instance of EnumMeta and
inherit from Enum

It is not obvious to me that Color is an instance
of EnumMeta. Is it a python rule that if a class C
inherit from a class which is an instance of
a metaclass, then class C is an instance of the
same metaclass too ?

Or was it feasible to guess that ?




--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to