I'm trying to understand metaclasses.
I already read this answer and I tried to use a custom __call__
like this :
#!/usr/bin/env python3
class MetaTest(type):
def __call__(cls, *args, **kwargs):
print("MetaTest.__call__ called.")
return super().__call__(cls, *args, **kwargs)
class Test:
__metaclass__ = MetaTest
if __name__ == '__main__':
Test()
I expected Test.__class__.__call__
to be called at instanciation, and Test.__class__
to be an instance of MetaTest
, but it's not the case since I don't have an output when running this script.
So why isn't MetaTest.__call__
called at Test
instanciation?