What is the difference between type and type.__new__ in python?
- by Jason Baker
I was writing a metaclass and accidentally did it like this:
class MetaCls(type):
def __new__(cls, name, bases, dict):
return type(name, bases, dict)
...instead of like this:
class MetaCls(type):
def __new__(cls, name, bases, dict):
return type.__new__(cls, name, bases, dict)
What exactly is the difference between these two metaclasses? And more specifically, what caused the first one to not work properly (some classes weren't called into by the metaclass)?