creating many similar properties
Michele Simionato
michele.simionato at gmail.com
Thu Oct 19 03:49:46 EDT 2006
James Stroud wrote:
> However, I think that what you are saying about metaclasses being
> brittle relates more to implementation than language. In theory, these
> should be equivalent:
>
> (1) class Bob(object): pass
> (2) Bob = type('Bob', (), {})
>
> And indeed a cursory inspection of the resulting classes show that they
> are indistinguishable.
>
> That they wouldn't be seems an implementation bug and perhaps that bug
> should be fixed rather than promoting the avoidance of (2) because it
> does not create classes that behave as number (1).
You got something wrong ;)
'type' is the builtin metaclass, it works, I have nothing against it,
and (1) and (2) are *exactly*
equivalent. My gripe is against *custom* metaclasses, i.e. subclasses
of 'type'. The paper is
all about avoiding custom metaclasses and using 'type' instead (i.e.
use the __metaclass__
hook, but not custom metaclasses). It is the same trick used by George
Sakkis in this same
thread.
Michele Simionato
More information about the Python-list
mailing list