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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:31:58+00:00 2026-06-01T08:31:58+00:00

Assume I have classes A1 and A2 and a class B that has elements

  • 0

Assume I have classes A1 and A2
and a class B that has elements of type A1/A2.

Now I have a class B'(B) (it inherits from B).
Can this class use A1′ and A2′ instead of A1 and A2,
can this new class somehow exchange the type of elements in the base class?

Normally I would say it’s impossible, but since this is about python… 😛

  • 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-01T08:31:59+00:00Added an answer on June 1, 2026 at 8:31 am

    You mean like this?

    class A1(object):
        pass
    
    class A1Child(A1):
        pass
    
    class A2(object):
        pass
    
    class A2Child(A2):
        pass
    
    
    class B(object):
    
        a1_instance = None
        a2_instance = None
    
        def __init__(self):
            self.a1_instance = A1()
            self.a2_instance = A2()
    
    class BChild(B):
    
        def __init__(self):
            self.a1_instance = A1Child()
            self.a2_instance = A2Child()
    
    
    b_instance = B()
    
    print b_instance.a1_instance
    print b_instance.a2_instance
    
    
    bchild_instance = BChild()
    
    print bchild_instance.a1_instance
    print bchild_instance.a2_instance
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML that looks like this: <ul class=toggleList> <li><input type=checkbox name=toggleCbx1 id=toggleCbx1
I have a number of LINQ classes that inherit from the same base class.
Suppose I have an event KeyPress subscribed to by various classes. Assume that Class
Assume I have the following classes class Genre { static hasMany=[author:Author] } class Author{
Assume I have a class foo, and wish to use a std::map to store
Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
Assume I have the following two classes: public class User : Entity { public
I often design system where I have a class in my system that has
Let Abstract be an abstract class, and A1,A2,...,An concrete classes that inherit from Abstact
Assume I have a class like this: public class Foo { public Bar RequiredProperty

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.