Does python support multi prototype.

xtian xtian at
Mon Aug 9 06:41:06 CEST 2004

Matteo Dell'Amico <della at> wrote in message news:<w54Qc.29647$OH4.805468 at>...
> angel wrote:
> > Java and cpp support one function name multi function prototype.
>  [...]
> > Does python support it?
> Not natively, but - if you really need them - there are modules that 
> make them possible.
> Have a look at 
> , and 
> maybe at 
> too.

One thing to note is that these Lisp-ish multimethods are more
powerful than Java- or C#-style method overloading, because the method
dispatch is done at runtime using the actual types of the arguments.
In Java and C# overload selection is done at compile time, so if
you've got, frex:

public class Thing {
    public void DoSomething(Integer val) {

    public void DoSomething(String val) {

    public void DoSomething(Object val) {

[and then]

Object o = "fish";
Thing t = new Thing();

... you'll always get the object version of DoSomething called,
because the declared type of o is Object.

Which always annoyed me.


More information about the Python-list mailing list