Beginner having a problem with classes
- by David
I'm working through O'Reilly's "Learning Python" and having a problem with classes. I think I understand the concept, but in practice have stumbled upon this problem.
Fron page 88-89:
>>> class Worker:
def __innit__(self, name, pay):
self.name=name
self.pay=pay
def lastName(self):
return self.name.split()[-1]
def giveRaise(self, percent):
self.pay*=(1.0+percent)
Then the book says "Calling the class like a function generates instances of a new type ...etc" and gives this example.
bob = Worker('Bob Smith', 50000)
This gives me this error:
TypeError: this constructor takes no arguments.
And then I start muttering profanities. So what am I doing wrong here?
Thanks for the help.