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 6770101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:16:20+00:00 2026-05-26T15:16:20+00:00

Possible Duplicate: Can Super deal with multiple inheritance? Python inheritance? I have a class

  • 0

Possible Duplicate:
Can Super deal with multiple inheritance?

Python inheritance? I have a class structure (below), and want the child class to call the __init__ of both parents. Is this possible to do in a ‘super’ way or is it just a terrible idea?

class Parent1(object):
    def __init__(self):
        self.var1 = 1

class Parent2(object):
    def _init__(self):
        self.var2 = 2

class Child(Parent1, Parent2):
    def __init__(self):
        ## call __init__ of Parent1
        ## call __init__ of Parent2
        ## super(Child, self).__init__()
  • 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-26T15:16:20+00:00Added an answer on May 26, 2026 at 3:16 pm

    Invocation via super doesn’t call all the parents, it calls the next function in the MRO chain. For this to work properly, you need to use super in all of the __init__s:

    class Parent1(object):
        def __init__(self):
            super(Parent1, self).__init__()
            self.var1 = 1
    
    class Parent2(object):
        def __init__(self):
            super(Parent2, self).__init__()
            self.var2 = 2
    
    class Child(Parent1, Parent2):
        def __init__(self):
            super(Child, self).__init__()
    

    In Python 3, you can use super() instead of super(type, instance).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can you call Directory.GetFiles() with multiple filters? How do you filter on
Possible Duplicate: Can Read-Only Properties be Implemented in Pure JavaScript? I have an Object
Possible Duplicate: How can I pre-set arguments in JavaScript function call? (Partial Function Application)
Possible Duplicate: Can distribute setuptools be used to port packages implemented in python 2
Possible Duplicate: Can I export and import Visual Studio 2010-extensions? I want to reinstall
Possible Duplicate: Can I set a breakpoint on 'memory access' in GDB? I have
Possible Duplicate: Passing a Int value to another class I have been trying to
Possible Duplicate: Can I split a Mercurial repository? I have a Mercurial repository with
Possible Duplicate: Can’t operator == be applied to generic types in C#? I have
Possible Duplicate: why does initializing subclasses require calling the super class's same init function?

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.