[Tutor] _init_() arguments

Steven D'Aprano steve at pearwood.info
Fri Sep 9 14:19:35 CEST 2011


Stu Rocksan wrote:

> class Complex:
>               def _init_(self, realpart, imagpart)


Special methods in Python have TWO underscores at the beginning and end. 
You need to call it __init__ rather than _init_.

Also, are you aware that Python already includes a built-in complex type?

 >>> complex(1, 2)
(1+2j)



-- 
Steven


More information about the Tutor mailing list