Another way to spell __metaclass__ ?
Michael Hudson
mwh at python.net
Mon Dec 16 07:50:25 EST 2002
Thomas Heller <theller at python.net> writes:
> Mike Dean <klaatu at evertek.net> writes:
>
> > On 13 Dec 2002 19:34:04 +0100 Thomas Heller <theller at python.net> wrote:
> > > Didn't Michael Hudson some time ago have a patch which allowed
> > > to write something like this?
Yep.
> > > class IUnknown(bases) [interface]:
> > > ...
> >
> > > or
> >
> > > def IUnknown() [a, b, c]:
> > > ...
> >
> > I think I remember seeing something like that a long time ago (well,
> > long time relative to my Python activity). Was it for metaclasses, or
> > was it for some kind of interface mechanism?
It apparently resembles something from C#, so it could be that.
> IIRC, the list on the right was a list of callables which would have
> been invoked before or after the object on the left (class or
> function) is or was created. So it could be used to make class- or
> static methods, or to hook the class creation.
I only implemented it for `def' statements. It's slightly harder to
see how it would work in `class' statements. I guess
class Foo(base) [whatever]:
a = b
could be made equivalent to
Foo = whatever('Foo', (base,), {'a': b})
(so morally `whatever' defaults to `type'), but it's then hard to see
how that would chain (the righthand most function would seem to have
to have a different signature to the others).
> I don't know how long your Python activity is, but I think it was this
> year. Maybe a search on the python-dev archives will find it.
I don't think I posted the patch anywhere, and I don't think I still
have it. OTOH, it wasn't very hard -- I'm pretty sure I could
recreate it in a couple of hours.
I have a cunning plan to write a PEP targeted at Python 2.4 for this
fairly soon after 2.3 gets out. It's probably too late for 2.3 and it
rather defeats the "no new syntax" goal...
Cheers,
M.
--
Hey, if I thought I was wrong, I'd change my mind. :)
-- Grant Edwards, comp.lang.python
More information about the Python-list
mailing list