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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:18:06+00:00 2026-06-01T16:18:06+00:00

class A (object): keywords = (‘one’, ‘two’, ‘three’) class B (A): keywords = A.keywords

  • 0
class A (object):
    keywords = ('one', 'two', 'three')

class B (A):
    keywords = A.keywords + ('four', 'five', 'six')

Is there any way to change A.keywords to <thing B derives from>.keywords, sort of like super(), but pre-__init__/self? I don’t like repeating class names in definitions.

Usage:

>>> A.keywords
('one', 'two', 'three')
>>> B.keywords
('one', 'two', 'three', 'four', 'five', 'six')
  • 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-01T16:18:07+00:00Added an answer on June 1, 2026 at 4:18 pm

    Actually, you can. Write a descriptor that checks the class’s bases for an attribute with the same name and add the passed attributes to its value.

    class parentplus(object):
        def __init__(self, name, current):
            self.name = name
            self.value = current
    
        def __get__(self, instance, owner):
            # Find the attribute in self.name in instance's bases
            # Implementation left as an exercise for the reader
    
    class A(object):
        keywords = ('one', 'two', 'three')
    
    class B(A):
        keywords = parentplus('keywords', ('four', 'five', 'six'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have the Class object (an object that reference a Class) so you can
I've got the class object for an enum (I have a Class<? extends Enum>
How to get class object of a generic interface? For example, Boolean.class, Date.class. But
Trying to add a class object into a List using reflection, but when invoking
What is the use of creating base class object using child class reference in
How to instantiate a derived class object, whose base class ctor is private? Since
How to cast a pointer to void object to class object?
I'm trying to figure out how to instantiate a case class object with reflection.
What I am trying to achieve is something like this: class object: def __init__(self):
D2.0 classes have a __monitor class property that gives access to the class object's

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.