No method overloading

Fredrik Lundh fredrik at
Sun Aug 24 10:25:07 CEST 2008

Hussein B wrote:

> Please correct me if I'm wrong but Python doesn't support method
> overload, right?
> --
> def method(self):
>  #code
> def method(self, data):
>  #code
> --
> The last declaration of method() erase the previous one (like
> JavaScript).

in Python, methods are callable attributes, and an attribute can only 
have one value.  you can use default arguments to work around this:

   def method(self, data=None):
     if data is None:


More information about the Python-list mailing list