[Tutor] Classses

Jeff Shannon jeff@ccvcorp.com
Fri, 24 May 2002 10:04:18 -0700


Oops, my mailer mangled the quoting on that.  Here's the properly
formatted version...


-------- Original Message --------
Subject: Re: [Tutor] Classses
Date: Fri, 24 May 2002 09:56:48 -0700
From: Jeff Shannon <jeff@ccvcorp.com>
To: Tutor@python.org


Richard Gelling wrote:

> class Address:
>     def _init_(self,Hs,Town,Zip)
>         self.Hs_Number=Hs
>         self.Street=St
>         self.Town=Town
>         self.Zip_Code=Zip
>
> Which appears to work fine,however when type in the second part ie
>
> addr=Address(7,"High St.","Anytown","12345")
> [...]

Others have already pointed out your problem with _init_ versus
__init__, but I wanted to mention that you've got another bug lurking
here.  In your constructor, you have the line "self.Street = St" ...
but you don't have St in your argument list!  So, when you fix your
underscores and run this again, you'll still get an error, saying that
the constructor takes exactly four arguments (five given).

Jeff Shannon
Technician/Programmer
Credit International