Lines Matching refs:metaclass
1938 The metaclass hint ``metaclass`` is consumed by the rest of the type
1940 The actual metaclass (rather than the explicit hint) can be accessed as
1979 single: metaclass
1987 The class creation process can be customized by passing the ``metaclass``
1995 class MyClass(metaclass=Meta):
2002 passed through to all metaclass operations described below.
2007 * the appropriate metaclass is determined;
2027 Determining the appropriate metaclass
2030 single: metaclass hint
2032 The appropriate metaclass for a class definition is determined as follows:
2034 * if no bases and no explicit metaclass are given, then :func:`type` is used;
2035 * if an explicit metaclass is given and it is *not* an instance of
2036 :func:`type`, then it is used directly as the metaclass;
2037 * if an instance of :func:`type` is given as the explicit metaclass, or
2038 bases are defined, then the most derived metaclass is used.
2040 The most derived metaclass is selected from the explicitly specified
2041 metaclass (if any) and the metaclasses (i.e. ``type(cls)``) of all specified
2042 base classes. The most derived metaclass is one which is a subtype of *all*
2053 single: __prepare__ (metaclass method)
2055 Once the appropriate metaclass has been identified, then the class namespace
2056 is prepared. If the metaclass has a ``__prepare__`` attribute, it is called
2057 as ``namespace = metaclass.__prepare__(name, bases, **kwds)`` (where the
2064 If the metaclass has no ``__prepare__`` attribute, then the class namespace
2103 ``metaclass(name, bases, namespace, **kwds)`` (the additional keywords
2116 In CPython 3.6 and later, the ``__class__`` cell is passed to the metaclass
2122 When using the default metaclass :class:`type`, or any metaclass that ultimately
2163 In particular, the metaclass :class:`abc.ABCMeta` implements these methods in
2182 Note that these methods are looked up on the type (metaclass) of a class. They
2291 a class is known as that class's :term:`metaclass`, and most classes have the
2292 :class:`type` class as their metaclass. :class:`type` does not define
2297 >>> # list has class "type" as its metaclass, like most classes:
2309 However, if a class has a custom metaclass that defines
2319 >>> # Enum classes have a custom metaclass:
2813 sometimes referred to as 'metaclass confusion', and is avoided by bypassing
2823 :meth:`~object.__getattribute__` method even of the object's metaclass::
2830 >>> class C(object, metaclass=Meta):