Metaclass with name overloading.

David Mertz, Ph.D. at
Thu Sep 30 05:46:03 CEST 2004

Jacek Generowicz <jacek.generowicz at> wrote:
> I would like to write a metaclass which would allow me to overload
> names in the definition of its instances, like this
> class Foo(object):
>       __metaclass__ = OverloadingClass
>      def meth(self):
>         pass
>     def meth(self, arg):
>         return arg

It's not the literal syntax you're asking for, but using my technique
for multiple dispatch in Python achieves the effect you're looking
for.  It has nothing to do with metaclass, but it lets you provide
multiple "signatures" for a call.  Not just number of arguments, but
also their types (if you want: you can also generically specify a
descendent of object).

for more details.

Yours, David...

More information about the Python-list mailing list