1

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

1 Answer 1

4

You've misspelled __init__ as __int__. Does the error make sense in light of this?

Sign up to request clarification or add additional context in comments.

2 Comments

Oh dear god, that was the issue. Thanks.
I got you covered, there was a time restriction (10 min or so) on accepting the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.