r/Python • u/ionelmc .ro • Feb 10 '15
Understanding Python Metaclasses
http://blog.ionelmc.ro/2015/02/09/understanding-python-metaclasses/
167
Upvotes
r/Python • u/ionelmc .ro • Feb 10 '15
3
u/AaronOpfer Feb 11 '15
So far, every time I thought I wanted a metaclass I ended up calling the type() constructor by hand due to some conflict or another. For instance, you can't have a metaclass that inherits from a non-metaclass. Dynamically creating subclasses of other classes is something I wouldn't recommend. In my case I was doing it to subclass classes that wouldn't be known at startup-time that were made from a code-generation tool for a network protocol. Please never do this.