Overloading methods in C API

Robert Amesz sheershion at mailexpire.com
Sat Jan 18 14:22:49 EST 2003


Grant Edwards wrote:

>> Is method/function overloading common in Python modules?
> 
> No.  It's isn't supported.  The language does not allow it. 
> Therefore, it is not common.

It's not that the language doesn't allow it, it's just that dynamic 
typing makes it impossible to decide beforehand what methods/functions 
would be called.


>> Is it looked down upon?
> 
> It is not allowed by the language design. I suppose that's a
> pretty good indication that it's "looked down upon."

No, it's not "looked down upon". Take, for example, the % operator for 
strings: it allows things like:

   "Single value: %d" % 43

or:

   "Multiple values: %s %d" % ("one", 2)

or even:

   "Using a dict: %(first)s %(second)d" % {"first": "one", "second": 2}

That's a pretty overloaded function, if you ask me, and it's part of 
core Python. It's just that in Python you have to do this manually. Ah, 
well, "explicit is better than implicit", to coin a phrase.


Robert Amesz




More information about the Python-list mailing list