Steven D'Aprano wrote:
On Tue, Jun 05, 2012 at 10:20:58AM +0300, Eli Bendersky wrote:
Still, instance of type()" is a bit too cryptic for mere mortals, IMHO.
I think that if somebody finds "instance of type" too cryptic, they
won't have any chance at all to understand metaclasses.
Personally, I think there is a lot confusing about metaclasses, but the
idea that classes are instances (objects) is not one of them.
One thing that *is* confusing is that the metaclass parameter in class
creation is not the metaclass (class of the class), but the class
factory. For example:
def silly(*args):
print(*args)
return int
class C(metaclass=silly):
def m(self): pass
C () {'m': <function C.m at 0xb721fe14>, '__qualname__': 'C',
'__module__': '__main__'}
print(C)
int
In this example the metaclass (ie the class of C) is type (C is int),
even though the declared metaclass is 'silly'.
I assume it is too late to change the name of the 'metaclass' keyword to
'factory', but we could use that terminology in the docs.
Cheers,
Mark
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com