Top "Metaclass" questions

In object-oriented programming, a metaclass is a class whose instances are classes.

Using the __call__ method of a metaclass instead of __new__?

When discussing metaclasses, the docs state: You can of course also override other class methods (or add new methods); for …

python oop metaclass
Using abc.ABCMeta in a way it is compatible both with Python 2.7 and Python 3.5

I'd like to create a class which has abc.ABCMeta as a metaclass and is compatible both with Python 2.7 and …

python python-2.7 metaclass python-3.5 abc
Understanding __init_subclass__

I finally upgraded my python version and I was discovering the new features added. Among other things, I was scratching …

python class subclass python-3.6 metaclass
Is there a way to set metaclass after the class definition?

In order to set metaclass of a class, we use the __metaclass__ attribute. Metaclasses are used at the time the …

python metaclass
Understanding metaclass and inheritance in Python

I have some confusion regarding meta-classes. With inheritance class AttributeInitType(object): def __init__(self,**kwargs): for name, value in kwargs.…

python inheritance metaclass
Auto-register class methods using decorator

I want to be able to create a python decorator that automatically "registers" class methods in a global repository (with …

python oop design-patterns decorator metaclass
Metaclass multiple inheritance inconsistency

Why is this: class MyType(type): def __init__(cls, name, bases, attrs): print 'created', cls class MyMixin: __metaclass__ = MyType class …

python metaclass
How to wrap every method of a class?

I'd like to wrap every method of a particular class in python, and I'd like to do so by editing …

python wrapper metaclass
Triple inheritance causes metaclass conflict... Sometimes

Looks like I stumbled upon a metaclass hell even when I didn't wanted anything to do with it. I'm writing …

python oop qt4 multiple-inheritance metaclass
Automatically setting an enum member's value to its name

I've been messing around with python's enum library and have come across a conundrum. In the docs, they show an …

python enums metaprogramming metaclass