inline metaclasses
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Mon Jul 3 18:29:39 EDT 2006
In <1151952177.002598.40850 at b68g2000cwa.googlegroups.com>, gangesmaster
wrote:
> just something i thought looked nice and wanted to share with the rest
> of you:
>
>>>> class x(object):
> ... def __metaclass__(name, bases, dict):
> ... print "hello"
> ... return type(name, bases, dict)
> ...
> hello
>>>>
>
> instead of defining a separate metaclass function/class, you can do
> it inline. isn't that cool?
But why use a metaclass? If the meta class is only applied to *one*
class, can't you do at class level whatever the metaclass is doing!?
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list