0
class Factor:
    def __int__(self, a, b, c):
        self.a = a
        self.b = b
        self.c = c

a = input("What is A?")
a = int(a)
b = input("What is B?")
b = int(b)
c = input("What is C?")
c = int(c)

e = Factor(a,b,c)

This is the error it returns for any class I create

Traceback (most recent call last):
  File "C:\Users\Alex\Desktop\Alex Factoring Extra Credit.py", line 37, in <module>
    e = Factor(a,b,c)
TypeError: object.__new__() takes no parameters

It happens for any class I make and I have looked everywhere, uninstalled, and re-installed and yet I can not find a solution. I have copy and pasted classes I have found elsewhere and those will work, yet mine will work even though it is exactly the same. Any help is appreciated.

1 Answer 1

4

You didn't name your __init__ properly, you forgot an i.

class Factor:
    def __init__(self, a, b, c):

Without an __init__() method, the arguments are sent to the parent object.__new__() method, which doesn't take any arguments.

Demo on Python 3.3 (slightly updated error message):

>>> class Factor:
...     def __int__(self, a, b, c):
...         self.a = a
...         self.b = b
...         self.c = c
... 
>>> Factor(1, 2, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object() takes no parameters
>>> class Factor:
...     def __init__(self, a, b, c):
...         self.a = a
...         self.b = b
...         self.c = c
... 
>>> Factor(1, 2, 3)
<__main__.Factor object at 0x10a955050>
Sign up to request clarification or add additional context in comments.

1 Comment

Oh, Thank you. I feel like a fool now, but its always the little mistakes I guess.

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.