Metaclass with name overloading.
Alex Martelli
aleaxit at yahoo.com
Wed Sep 29 09:50:43 EDT 2004
Jacek Generowicz <jacek.generowicz at cern.ch> wrote:
> imbosol at aerojockey.com (Carl Banks) writes:
>
> > def alltuple(name,bases,clsdict):
> > return tuple(clsdict.values())
> > __metaclass__ = alltuple
>
> WBMSWA12FB !
>
> It never occurred to me that a metaclass didn't have to be a _class_.
You should have seen Guido's face when he first saw me give a
presentation on "use and abuse of custom metaclasses" -- apparently,
judging from his horrified expression, it hadn't occurred to him,
either, and he didn't like it half a bit... since then I've been quite
careful against actually using this idea in production code.
Actually I believed I showed something more like:
class whatever:
def __metaclass__(clsname, clsbases, clsdict):
return <I don't remember what>
...etc etc...
i.e., an "anonymous metaclass", so to speak. But that's a minor aspect.
After all, something like:
class yetanother:
class __metaclass__(type):
...etc etc...
is just as so-to-speak "anonymous" yet IS nowadays quite an accepted
idiom...!
Alex
More information about the Python-list
mailing list