Reputation: 1057
I'm leaning python and tried this code to test my 1st bit of OOP coding but I'm not sure how to fix this pesky error. This example of from Learning Python by mark Lutz 4th edition - Page 650. Any ideas?
#File person.py (start)
class Person:
def __int__(self, name, job=None, pay=0):
self.name = name
self.job = job
self.pay = pay
bob = Person('Bob Smith') #test the class
sue = Person('Sue Jones', job='dev', pay=100000)
print (bob.name, bob.pay)
print (sue.name, sue.pay)
Yeilds the following error:
Traceback (most recent call last): File "FILELOCATION/person.py", line 8, in bob = Person('Bob Smith') #test the class TypeError: object.new() takes no parameters
Upvotes: 1
Views: 634
Reputation: 6762
You've misspelled __init__
as __int__
. Does the error make sense in light of this?
Upvotes: 4