Instructions in book don't work

Dan Hamm dan at dmhamm.org
Thu Jan 10 11:25:03 EST 2002


Thanks for all your help - the two underscores did the trick. Thanks also for being such a helpful community - I'm sure I'm going to enjoy participating (and someday hopefully contributing) to the group.

Dan
  "Dan Hamm" <dan at dmhamm.org> wrote in message news:n5a%7.12404$fG.81756 at rwcrnsc51.ops.asp.att.net...
  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/8bcb9b77/attachment.html>


More information about the Python-list mailing list