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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:10:45+00:00 2026-05-17T15:10:45+00:00

Newbie Python question. I have a class that inherits from several classes, and some

  • 0

Newbie Python question. I have a class that inherits from several classes, and some of the specialization classes override some methods from the base class. In certain cases, I want to call the unspecialized method. Is this possible? If so, what’s the syntax?

class Base(object):
    def Foo(self):
        print "Base.Foo"

    def Bar(self):
        self.Foo()  # Can I force this to call Base.Foo even if Foo has an override?


class Mixin(object):
    def Foo(self):
        print "Mixin.Foo"


class Composite(Mixin, Base):
    pass


x = Composite()
x.Foo()  # executes Mixin.Foo, perfect
x.Bar()  # indirectly executes Mixin.Foo, but I want Base.Foo
  • 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-17T15:10:46+00:00Added an answer on May 17, 2026 at 3:10 pm

    you can specifically make the call you want using the syntax

    Base.Foo(self)
    

    in your case:

    class Base(object):
        # snipped
    
        def Bar(self):
            Base.Foo(self)  # this will now call Base.Foo regardless of if a subclass
                            # overrides it
    
    # snipped
    
    
    x = Composite()
    x.Foo()  # executes Mixin.Foo, perfect
    x.Bar()  # prints "Base.Foo"
    

    This works because Python executes calls to bound methods of the form

    instance.method(argument)
    

    as if they were a call to an unbound method

    Class.method(instance, argument)
    

    so making the call in that form gives you the desired result. Inside the methods, self is just the instance that the method was called on, i.e, the implicit first argument (that’s explicit as a parameter)

    Note however that if a subclass overrides Bar, then there’s nothing (good) that you can effectively do about it AFAIK. But that’s just the way things work in python.

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

Sidebar

Related Questions

I have another newbie Python question. I have the following piece of code that
I'm a newbie to python and the app engine. I have this code that
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
Apologies, somewhat confused Python newbie question. Let's say I have a module called animals.py
This is a python newbie question: I have the following directory structure: test --
Quick, newbie Python scoping question. How can I make sure that the original variables
I am a newbie to Python and have come across the following example in
Java Newbie here. I have a JFrame that I added to my netbeans project,
I am a Python newbie. I have this small problem. I want to print
a newbie question I have a Django project with two applications core and nagios

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.