Overloading __init__ & Function overloading

Steve Holden steve at holdenweb.com
Fri Sep 30 15:58:05 CEST 2005

Iyer, Prasad C wrote:
> I am new to python.
> I have few questions
> a. Is there something like function overloading in python?

Not in the same way as Java: you can't write several functions and have 
the compiler or run-rime system work out which one to call according to 
argument types. Don't forget that Python is so dynamic that the types of 
a function's arguments may vary between successive iterations of the 
same statement.

> b. Can I overload __init__ method
The normal way to do this is to have the subclass's __init__ call the 
superclass's __init__, usually right at the start.

When you get deeply into Python you will learn that you even call a 
function to determine the right superclass on which to call __init__.

What is "super()"?

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/

More information about the Python-list mailing list