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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:15:48+00:00 2026-06-16T07:15:48+00:00

Given a class and other classes that extend it either directly or indirectly. Is

  • 0

Given a class and other classes that extend it either directly or indirectly. Is there a way to get all the classes that directly extend the original class.

class Alpha(object):
    @classmethod
    def get_derivatives(cls):
        return [Beta, ] # when called from Alpha
        return [] # when called from Beta

class Beta(Alpha):
    pass

I’m guessing there are some complications or it is impossible altogether. There would have to be some specification as to where the derived classes are defined, which would make things tricky…

Is my best bet to hard-code the derived classes into the base one?

  • 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-16T07:15:49+00:00Added an answer on June 16, 2026 at 7:15 am

    Perhaps you are looking for the __subclasses__ method:

    class Alpha(object):
        @classmethod
        def get_derivatives(cls):
            return cls.__subclasses__() 
    
    class Beta(Alpha):
        pass
    
    print(Alpha.get_derivatives())
    print(Beta.get_derivatives())
    

    yields

    [<class '__main__.Beta'>]
    []
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a class class RandomName extends CommonAppBase {} is there any way to automatically
Given a base class that is inherited by plethora of derived classes, and a
Imagine having a main class -- Simulator -- that uses two other classes --
I'm designing/building a system of classes that all derive from a single base class.
I have several queues that all extend a Queue class. I want to do
In other words, given a base class shape and a derived class rectangle :
I have method that returns module path of given class name def findModulePath(path, className):
I understand that CoCreateInstance finds the COM server for the given class id, creates
Possible Duplicate: How do you find all subclasses of a given class in Java?
I am writing for a bigger project a system that different classes registers there

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.