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

  • Home
  • SEARCH
  • 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 6240045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:29:48+00:00 2026-05-24T11:29:48+00:00

I have an odd question, and seeing as the real context is fairly complex

  • 0

I have an odd question, and seeing as the real context is fairly complex I’ve made a simple example. I have two classes Base and Child. Each share a method of the the same name go. What I want the Child class to be able to do is inherit the go method from Base. However, when I call the go method on Child I want it to do some things (In this case multiply the attribute A by 2), then call the go method that it inherited from Base.

In this example calling go on Base would print 35, while I want Child to print 70.

class Base :
    def __init__ (self) :
        self.A = 35

    def go (self) :
        print self.A


class Child (Base) :
    def __init__ (self) :
        Base.__init__(self)

    def go (self) :
        self.A = self.A * 2

        # Somehow call Base's **go** method, which would print 70.

I understand that it’s typically not a good idea to do this (seeing as it could be confusing), however in the context of what I’m doing it makes sense.

  • 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-24T11:29:48+00:00Added an answer on May 24, 2026 at 11:29 am

    This is absolutely a fine thing to do. What you’re looking for is super().

    class Child (Base):
        def __init__ (self):
            super(Child, self).__init__()
    
        def go(self):
            self.A = self.A * 2
            super(Child, self).go()
    

    In Python 3 you can use it without arguments because it will detect the correct ones automatically.

    Edit: super() is for new-style classes, which you should use anyway. Just declare any class which doesn’t inherit from another as inheriting from object:

    class Base(object):
    

    Also, all those extra spaces before and after parenthesis are not considered good python style, see PEP8.

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

Sidebar

Related Questions

I have an odd question here. I have two animations set up for a
I have an odd need to open two separate instances of excel and having
I have a bit of an odd question. My situation is as following: I
Kind of an odd question, but I have a game I am making for
This is an odd question. I have a friend who is working on an
This may seem like an odd question, but I have my own reasons for
I guess this is kind of an odd question but I have tried setting
I have an odd problem...I'm using a documentation generator which generates a lot of
I have an odd edge case right now in that a response code from
I have an odd problem in VS2008 running unit tests. When I run the

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.