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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:24:55+00:00 2026-05-26T05:24:55+00:00

I have been working on a multiple inheritance code which looks similar to this:

  • 0

I have been working on a multiple inheritance code which looks similar to this:

class Document():
    def save(self, x):
        print "inside Document from " + x

class Cdm(object):
    def save(self,x):
        print "inside Cdm from " + x
        super(Cdm,self).save('Cdm')

class Contacts(Cdm, Document):
    def __init__(self):
        self.save('Contacts')  

This is the result I get when I create an instance of Contacts.

> c = Contacts()
< inside Cdm from Contacts
< inside Document from Cdm

Now this is just weird, possibly to my eye. I might have misunderstood something. As you can see, the class Contacts inherits from cdm and Document. I am trying to use the save method of Cdm from Contacts. But Cdm inherits from object and does not have a super class method called save yet it calls the save function from Document class. In the program what I am working this is the behaviour I want but I am worried as theoretically it should not work or at least I think.

Do you have any comments on this. Or have I misunderstood Python’s inheritance.

  • 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-26T05:24:56+00:00Added an answer on May 26, 2026 at 5:24 am

    As Python documentation says:

    super(): Return a proxy object that delegates method calls to a parent or sibling class of type.

    In that situation, super(Cdm,self).save('Cdm') will call the version of save() which is next in method resolution order. In that case it is the save() method in the Document class because it is a sibling class of Cdm (i.e. it is the second base class of Contacts).

    A great practical explanation of super() can be found here: Python’s super() considered super!

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

Sidebar

Related Questions

I have been working on some legacy C++ code that uses variable length structures
So I have been working with multiple different MS Access apps at work (about
I have been working on a web page and would like to load multiple
I have been working on this for 1 hour with no such luck. Any
I've been working on a Windows SideBar Gadget wherein I have multiple flyout pages.
I have a winforms application i have been working on that runs multiple tests
I have been working on a SWT-based project which is intended to be deployed
I have been working with the following code published on msdn: http://msdn.microsoft.com/en-us/library/fx6588te.aspx I understand
I have been working on a web services related project for about the last
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)

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.