Instructions in book don't work

Dan Hamm dan at dmhamm.org
Thu Jan 10 00:59:47 EST 2002


This is my very first attempt at using a newsgroup, so please bear with me. I am totally new to programming, and picked up the book "Lean to Program Using Python" by Alan Gauld. The problem I am trying to solve is this:

On page 51 the author shows demonstration code for setting up a class - 

>>> class Address:
...  def _init_(self, Hs, St, Town, Zip):
...     self.Hs_Number = Hs
...     self.Street = St
...     self.Town = Town
...     self.Zip_Code = Zip

Then follows it up with the instructions to type in the following -

>>> addr = Address(7,"High St.","Anytown","12345")
>>> print addr.Hs_Number, addr.Street

My problem is when I type the first line of the second set of instructions (addr = Address(7, ...) I get the following error -

Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: this constructor takes no arguments

I've checked to make sure I copied exactly what was in the book, but it just doesn't seem to work. Can anyone tell me where I went wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20020110/53c22fbd/attachment.html>


More information about the Python-list mailing list