On Fri, Dec 09, 2005 at 06:29:12PM +0100, Johannes Reichel wrote:
> Hi!
> 
> 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:
    class Complex:
        def __init__(self, real=0, imag=0):
            self.real = real
            self.imag = imag

> And by the way, is it possible to overload operators like +,-,*?
> 
> def operator+(self,complex2):

The special methods have names like __add__.
    http://docs.python.org/ref/numeric-types.html

Jeff

Attachment: pgpBaCTVXSEn0.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to