On 5 Jun 2012, at 09:34, Mark Shannon wrote:

> 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.


Well, the same was always true in Python 2 as well - __metaclass__ could be a 
function that was identically "silly". The real "metaclass" (type of the class) 
is whatever you use to construct the class. 

Michael

> 
> 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/fuzzyman%40voidspace.org.uk
> 


--
http://www.voidspace.org.uk/


May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing 
http://www.sqlite.org/different.html





_______________________________________________
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

Reply via email to