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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:01:19+00:00 2026-05-15T13:01:19+00:00

I was reading the Python docs about classes and came across this paragraph which

  • 0

I was reading the Python docs about classes and came across this paragraph which I’m not sure about:

Derived classes may override methods
of their base classes. Because methods
have no special privileges when
calling other methods of the same
object, a method of a base class that
calls another method defined in the
same base class may end up calling a
method of a derived class that
overrides it. (For C++ programmers:
all methods in Python are effectively
virtual.)

Example:

class A:
    def foo(self):
        self.bar()

    def bar(self):
        print "from A"

class B(A):
    def foo(self):
        self.bar()

    def bar(self):
        print "from B"

Does this mean that an object of class A obj = A() can somehow end up printing “from B”? Am I reading this correctly? I apologize if this doesn’t make sense. I’m a bit confused as to how python handles Inheritance and overriding. Thanks!

  • 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-15T13:01:19+00:00Added an answer on May 15, 2026 at 1:01 pm

    No. There’s no way the superclass can know anything about the subclass. What it means is if you instantiate the subclass B, and it inherits a method foo(), and overrides a method bar(), then when you call foo(), that will call the bar() definition in B, not the bar() definition in A. This is not what the superclass writer intended – he expected his call to bar() to go to his own definition.

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

Sidebar

Related Questions

Once when I was reading some python docs I came across a reference to
when reading a python ndb api of google app engine, I cam across this
I've been reading the Python 3.2 docs about string formatting but it hasn't really
I am reading this http://docs.python.org/dev/library/multiprocessing.html In particular this p = multiprocessing.Process(target=time.sleep, args=(1000,)) I tried
I have been reading about creating an RPM for Python 2.6.4. In this page:
I've been reading about Python's urllib2's ability to open and read directories that are
When I first started reading about Python, all of the tutorials have you use
i'm reading the Gray Hat Python,, i reach for this :: class debugger(): def
My question is about Python List Comprehension readability. When I come across code with
I've been reading about Python's multiprocessing module . I still don't think I have

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.