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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:34:19+00:00 2026-05-12T14:34:19+00:00

How can I iterate over a list of all classes loaded in memory? I’m

  • 0

How can I iterate over a list of all classes loaded in memory?
I’m thinking of doing it for a backup, looking for all classes inheriting from db.Model (Google App Engine).

Thanks,
Neal Walters

  • 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-12T14:34:19+00:00Added an answer on May 12, 2026 at 2:34 pm

    In “normal” Python, you can reach all objects via the gc.getobjects() function of the gc standard library module; it’s then very easy to loop on them, checking which one are classes (rather than instances or anything else — I do believe you mean instances of classes, but you can very easily get the classes themselves too if that’s really what you want), etc.

    Unfortunately, the gc module in App Engine does NOT implement getobjects — which makes it extremely difficult to reach ALL classes. For example, a class created by calling:

    def makeaclass():
      class sic(object): pass
      return sic
    

    and hidden into a list somewhere, IS going to be very difficult to reach.

    But fortunately, since you say in your question’s text that you only care about subclasses of db.Model, that’s even easier than gc would allow:

    for amodel in db.Model.__subclasses__():
       ...
    

    Just make sure you explicitly ignore such classes you don’t care about, such as Expando;-).

    Note that this DOES give you only and exactly the CLASSES, not the instances — there is no similarly easy shortcut if those are what you’re really after!

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

Sidebar

Related Questions

I know that I can iterate over an object's properties like this: for (property
I'm trying to find out how I can iterate over the final results of
How can i iterate over the (public or private) properties of a php class?
In Python I can use the iterkeys() method to iterate over the keys of
I have a vector of IntRect: vector. How can I iterate from both ends
I'm trying to iterate through all nodes, so I can print them out for
Im trying to iterate over a nestled dict list. The first level works fine.
How can I iterate over HTML nodes of a web page and get the
In a worker thread, I iterate over a list of items that need updating.
I'd like to iterate over a list of distinct fields in a given document.

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.