Overloading methods in C API

Steve Holden sholden at holdenweb.com
Sat Jan 18 16:40:38 CET 2003


"Afanasiy" <abelikov72 at hotmail.com> wrote in message
news:bsoi2v4rokh97unbdnfa9pndd8cctjd6ru at 4ax.com...
> On 18 Jan 2003 12:55:08 +0100, martin at v.loewis.de (Martin v. Löwis)
> wrote:
>
> >Afanasiy <abelikov72 at hotmail.com> writes:
> >
> >> How is it expected I create overloaded methods/functions in the C API?
> >
> >This is not possible. Overloading of methods is not supported in Python.
>
> Is method/function overloading common in Python modules?
> Is it looked down upon?

Well, it isn't like anybody said "We'll leave out method and function
overloading, and that will fix those *@#$! [language of your choice]
devotees". More that it simply isn't a part of the language design.

Python's signature-based polymorphism doesn't allow for multiple signatures
to be associated with the same method or function. Consequently if you want
to perform different functionsa ccording to the arguments provided, you have
to do the decoding yourself as a part of the logic of your method/function.

Personally I think this is good, and fits well with Python's general
"explicit is better than implicit" philosophy (though where that leaves
properties is another question, currently being discussed on a thread not
far from here).

Of course, many of Python's operators are tied to methods "under the hood",
so you can get operator overloading in the same way for many operators.

regards
--
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Bring your musical instrument to PyCon!    http://www.python.org/pycon/







More information about the Python-list mailing list