[Tutor] Classses

Andrei Kulakov ak@silmarill.org
Fri, 24 May 2002 04:19:46 -0400


On Fri, May 24, 2002 at 09:08:14AM +0100, Richard Gelling wrote:
> Hi,
> 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)
>

It should be __init__, with four underlines (you have two).

>                   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")
> 
> I get the error :
> 
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> TypeError: this constructor takes no arguments
> 
> Could someone explain what is going wrong here.I am unable to see what i am
> doing wrong.I have typed it in exactly as it is in the book and Have tried
> it on 2 working machines.I would be most grateful if someone could enlighten
> me,As i dont really want to continue until i see what i am doing wrong.
> 
> 
> Thanks a lot 
> R.Gelling
> 
> Registered Linux User : 256848
-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org