Overloading

Josef Meile jmeile at hotmail.com
Fri Dec 9 14:49:00 EST 2005


>>> In C++ you can overload functions and constructors. For example if I 
>>> have a
>>> class that represents a complex number, than it would be nice if I can
>>> write two seperate constructors
>>
>>
>>
>> Python doesn't support this, but it does support default arguments:
> 
> Yes, in part you are right since the python core doesn't include them.
> However they can be implemented with decorators:
> 
> * Subject: decorators and multimethods
>   Group:   comp.lang.python
>   Link:    http://tinyurl.com/d45ym
There is even a better recipe, explained step by step from Guido:
* Five-minute Multimethods in Python
   Link: http://tinyurl.com/8ppd6

Regards
Josef




More information about the Python-list mailing list