Beginner's question - class definition
banksam at swanhill.net.au
banksam at swanhill.net.au
Mon Jan 15 16:14:20 EST 2001
Can anyone explain please why the following definition ( from the
Python documentation)
class Complex:
def _init_(self, realpart, imagpart):
self.r = realpart
self.i = imagpart
when followed by the following attempt to create an instance
x = Complex(3.0,-4.5)
gives this error message
Traceback (innermost last):
File "<pyshell#5>", line 1, in ?
x = Complex(3.0,-4.5)
TypeError: this constructor takes no arguments
So far I have had the same error message from any similar definitions
taken from other tutorials. I am clearly doing something wrong, but I
don't know what.
Arthur Banks
More information about the Python-list
mailing list