[Tutor] Classses
Alexandre Ratti
alex@gabuzomeu.net
Fri, 24 May 2002 11:07:18 +0200
Hi Richard,
At 04:09 24/05/2002 -0400, tutor-request@python.org wrote:
>Date: Fri, 24 May 2002 09:08:14 +0100 (GMT Daylight Time)
>From: "Richard Gelling" <tombraider500@yahoo.co.uk>
>Subject: [Tutor] Classses
>I am reading Alan Gauld and have got a bit stuck.I am up to reading about
>classes and have typed in his example i.e
>
>class Address:
> def _init_(self,Hs,Town,Zip)
You need to use double underscores. In Python, special method names are
wrapped in double underscores. And you need a colon at the end of the line
(maybe it was included in your code; I received a garbled message).
def __init__(self, Hs, Town, Zip):
> self.Hs_Number=Hs
> self.Street=St
> self.Town=Town
> self.Zip_Code=Zip
>TypeError: this constructor takes no arguments
The interpreter did not recognise your "__init__" as a valid constructor;
hence it used a default one with no arguments.
Cheers.
Alexandre