Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6077489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:43:35+00:00 2026-05-23T10:43:35+00:00

I made a small chunk of code because I’m still trying to figure out

  • 0

I made a small chunk of code because I’m still trying to figure out the specifics of using super(). Why does this chunk run to this TypeError?

 a = SecondClass()
TypeError: __init__() takes exactly 2 arguments (1 given)

Then, the SecondClass.meth() function is supposed to print the string, but I’m clearly missing something conceptually.

class FirstClass (object):
    def __init__ (self, value):
        self.value = value
        print self.value

class SecondClass (FirstClass):
    def meth (self):
        super (FirstClass,self).__init__(value = "I am a strange string")

a = SecondClass()
a.meth()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:43:36+00:00Added an answer on May 23, 2026 at 10:43 am

    This isn’t anything to do with super. You don’t define an __init__ for SecondClass explicitly – but, because it inherits from FirstClass, it inherits FirstClass‘s __init__. So you can’t instantiate the object without passing in the value parameter.

    Edit OK. The first point, as others have mentioned, is that you must always use the current class in your super call, not the superclass – in this case super(SecondClass, self). That’s because super means “get the parent of class x”, so obviously you mean “get the parent of SecondClass” – which is FirstClass.

    The second point is that it doesn’t make sense to call the __init__ method inside meth. __init__ is already called when you instantiate the object. Either your subclass defines its own version, which can choose whether or not to call its own super method; or, as in this case, it doesn’t, in which case the superclass’s version is called automatically.

    Let me repeat that, because I suspect that this is the missing piece in your understanding: the whole point of subclassing is that anything you don’t specifically override, gets inherited anyway. super is only for those cases when you want to override something, but still use the logic from the super class as well.

    So here’s a silly example:

    class FirstClass(object):
        def __init__ (self, value="I am the value from FirstClass"):
            print value
    
        def meth(self):
            print "I am meth from FirstClass"
    
        def meth2(self):
            print "I am meth2 from FirstClass"
    
    class SecondClass(FirstClass):
        def __init__ (self):
            print "I am in SecondClass"
            super(SecondClass, self).__init__(value="I am the value from SecondClass")
    
        def meth(self):
            print "I am meth from SecondClass"
    
    
    a=FirstClass() # prints "I am the value from FirstClass"
    b=SecondClass() # prints *both* "I am in SecondClass" *and* "I am the value from SecondClass
    
    a.meth() # prints "I am meth from FirstClass"
    b.meth() # prints "I am meth from SecondClass"
    
    a.meth2() # prints "I am meth2 from FirstClass"
    b.meth2() # *also* prints "I am meth2 from FirstClass", because you didn't redefine it.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made a small tool that parses a chunk of text, does some simple
I made this small Java program using eclipse IDE. I have set the workspace
I've made a small program which has 2 buttons and each does certain thing.
I made a small WPF application to slide UserControls in and out, the problem
I made a small page ( http://www.ovlu.li ) using CMS Made Simple ( http://www.cmsmadesimple.org/
I made a small Rest webservice using Jersey 1.11. When i call the url
I've made a small 3D viewer application using DirectX 9.0. Now I would like
I made a small application using XCode. How can i create a application package
I've made a small app where Form is threaded (using BackgroundWorker ), and in
I made this small location class so that I can better handle address information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.