Jonathan LaCour wrote:
> Guido van Rossum wrote:
>> This has usually been solved by creating a non-meta class whose only
>> purpose is to introduce the new metaclass. You'd write
>>
>> class TheLarch(KindsOfTrees, deciduous): ...
>>
>> and the metaclass would be called KindsOfTreesMeta.
>
> def of_type(metaclass):
> class MetaclassMixin(object):
> __metaclass__ = metaclass
> return MetaclassMixin
>
> ... and then I simply use this on my classes when I define them:
>
> class MyClass(of_type(SomeMetaclass)):
"of_type" doesn't really work for me - why not just name it "metaclass"?
def metaclass(meta):
class MetaclassMixin(object):
__metaclass__ = metaclass
return MetaclassMixin
class MyClass(metaclass(SomeMetaclass)):
pass
Off the top of my head, I can't see any reason this wouldn't work in the
case of multiple compatible metaclasses (due to inheritance).
Tim Delaney
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com