Python inheritance: TypeError: object.__init__() takes no parameters

0 votes

I get this error:

TypeError: object.__init__() takes no parameters 

when running my code, I don't really see what I'm doing wrong here though:

class IRCReplyModule(object):

    activated=True
    moduleHandlerResultList=None
    moduleHandlerCommandlist=None
    modulename=""

    def __init__(self,modulename):
        self.modulename = modulename


class SimpleHelloWorld(IRCReplyModule):

     def __init__(self):
            super(IRCReplyModule,self).__init__('hello world')
Nov 15, 2018 in Python by Anirudh
• 2,060 points
335 views

1 answer to this question.

0 votes

You are calling the wrong class name in your super() call:

class SimpleHelloWorld(IRCReplyModule):

     def __init__(self):
            #super(IRCReplyModule,self).__init__('hello world')
            super(SimpleHelloWorld,self).__init__('hello world')

Essentially what you are resolving to is the __init__ of the object base class which takes no params.

Its a bit redundant, I know, to have to specify the class that you are already inside of, which is why in python3 you can just do: super().__init__()

answered Nov 15, 2018 by Nymeria
• 3,500 points

Related Questions In Python

0 votes
1 answer

Python TypeError: 'list' object is not callable.

The error says the list is not ...READ MORE

answered Feb 8 in Python by Omkar
• 67,120 points
987 views
0 votes
1 answer

Python Pandas error: AttributeError: 'DataFrame' object has no attribute 'rows'

There is no attribute called “rows”. The ...READ MORE

answered Mar 28 in Python by Shri
1,219 views
0 votes
1 answer

Python error "TypeError: Can't convert 'int' object to str implicitly"

Hey Yamini, you cannot concatenate a string ...READ MORE

answered May 31 in Python by Gargi
66 views
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 128 views
0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,500 points
605 views
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,500 points
3,613 views