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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:43:25+00:00 2026-06-02T13:43:25+00:00

My base code looks like this: class C1(object): def f(self): return 2*self.g() def g(self):

  • 0

My base code looks like this:

class C1(object):
    def f(self):
    return 2*self.g()

    def g(self):
    return 2

class C2(C1):
    def f(self):
    return 3*self.g()


class C3(C1):
    def g(self):
        return 5

class C4(C3):
    def f(self):
    return 7*self.g()

obj1 = C1()
obj2 = C2()
obj3 = C3()
obj4 = C4()

Now my question is the following: I need to write three assignment statements that do the following:

  • assign the calling list for obj2.f() to the variable obj2_calls
  • assign the calling list for obj3.f() to the variable obj3_calls
  • assign the calling list for obj4.f() to the variable obj4_calls

Calling list being for example, when obj1.f() is called, the f method of C1 is called which calls the g method of C1. This could be represented as a calling list of the form ['C1.f', 'C1.g']

I don’t quite know the proper way to write the assignment statements and I desperately want to help out my friend with her stuff.

If you could just show me how to properly right out the first assignment statement, I’m sure I could figure out the rest.

  • 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-06-02T13:43:26+00:00Added an answer on June 2, 2026 at 1:43 pm

    The key insight is that if a method is not defined for a class, it will default to use the method of a class that the class inherits.

    Thus, ask yourself what ‘obj2.f()’ will do.

    • What class is obj2? It is C2.
    • Is there an f method defined for class C2? Yes, there is. So the method C2.f is called.
    • The C2.f method calls self.g, which means it looks for C2.g. Is there a ‘C2.g’ method? No, so we have to go to the class that C2 inherits from. The line class C2(C1) tells us that it is inherited from the class C1, so it will call the method C1.g.

    Those are the steps to get the first calling list; the rest are up to you.

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

Sidebar

Related Questions

My helper code looks like this (and works fine btw): module ProvidersHelper def call_to_review(provider)
This is what the current code looks like: public static class WidgetFactory { public
I have a repository pattern setup using NHibernate. The base class looks like this:
I have a base class that is a template that looks like this: template
Please take a look at this code: template<class T> class A { class base
Consider the following base code: (function($) { $.fn.myPlugin = function(settings) { return this.each(function() {
In our code base there is a function which should return either an object
The span tag currently looks like this: <span class='best_in_place<%= ' list-downvoted' if upload.downvoted? %><%=
Why does this init method return an object out of scope? Using XCode 4.2,
I'm trying to behaviorally test a Java object called StringReader. The code looks something

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.