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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:47:10+00:00 2026-05-31T04:47:10+00:00

I have a base class like this: class base(object): name = def __init__(self,name): self.user

  • 0

I have a base class like this:

class base(object):
    name = ""
    def __init__(self,name):
        self.user =user
    def context(self,value):
        return {}

Instead of this i created an another subclass and override this above “context” method:

class override(base):
    name = "New class"
    def context(self, value):
        a = []
        a = "hello","b"
        return a

I want to create a plugins, all they have are different definitions (different value of list will return) for context method. So i want to do this by putting override functionality.

When i call this base.context function from an another file. Following things should be happen:

  1. The list i.e "a" (in override context method) should return it’s value to base context method first.

  2. After getting a value from override.context method, base.context will return that value to from where it’s called after making some changes into it.

But, When i call this base.description method it will return a value directly from override.description method. So i am not able to make that changes into it 🙁

  • 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-31T04:47:12+00:00Added an answer on May 31, 2026 at 4:47 am

    A few things in you question are a little confusing, but I think that what you want is something like this example (python2.7):

    class base(object):
        name = ""
    
        def __init__(self, name):
            self.user =user
    
        def context(self, value):
            return [value]
    
    
    class override(base):
        name = "override"
    
        def context(self, value):
            base_context = super(override, self).context(value)
            a = ["hello", "a"] + base_context
    
        def description(self):
            return "override description"
    

    The you can do the following:

    >>> a = override()
    >>> override.context("value")
    ["hello", "a", "value"]
    >>> override.description()
    "override description"
    

    However, calling these methods on base gives different results:

    >>> a = base()
    >>> a.context("value")
    ["value"]
    >>> base.description()
    Traceback (most recent call last):
        ...
    AttributeError: 'base' has no attribute 'description'
    

    Its not entirely clear if this is what you want though, because you refer to base.context getting a value from override.context, whereas it normally happens the other way around. The same goes for override.description. If you really want base.context to get a value from override.context this can be done through base.__subclasses__(), but you would have to deal with all subclasses of base, and this sort of usage is extremely uncommon (and usually undesirable).

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

Sidebar

Related Questions

I have a two models set up like this: class User < ActiveRecord::Base #
I have models like this class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() def
I have a Category object like this: def parent_default(context): ''' default parent id if
I have a base class like this: package MyClass; use vars qw/$ME list of
I have a base class Parent like this: using System; using System.Collections.Generic; using System.Text;
I have a declarative table defined like this: class Transaction(Base): __tablename__ = transactions id
I have three models that look something like this: class Bucket < ActiveRecord::Base has_many
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base
I have a model called Category which looks like this: class Category < ActiveRecord::Base
I have a model like this class Parent < ActiveRecord::Base :has_many :kids end class

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.