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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:40:00+00:00 2026-05-11T09:40:00+00:00

Suppose you have a python method that gets a type as parameter; is it

  • 0

Suppose you have a python method that gets a type as parameter; is it possible to determine if the given type is a nested class?
E.g. in this example:

def show_type_info(t):     print t.__name__     # print outer class name (if any) ...  class SomeClass:     pass  class OuterClass:     class InnerClass:         pass  show_type_info(SomeClass) show_type_info(OuterClass.InnerClass) 

I would like the call to show_type_info(OuterClass.InnerClass) to show also that InnerClass is defined inside OuterClass.

  • 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. 2026-05-11T09:40:01+00:00Added an answer on May 11, 2026 at 9:40 am

    AFAIK, given a class and no other information, you can’t tell whether or not it’s a nested class. However, see here for how you might use a decorator to determine this.

    The problem is that a nested class is simply a normal class that’s an attribute of its outer class. Other solutions that you might expect to work probably won’t — inspect.getmro, for example, only gives you base classes, not outer classes.

    Also, nested classes are rarely needed. I would strongly reconsider whether that’s a good approach in each particular case where you feel tempted to use one.

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

Sidebar

Ask A Question

Stats

  • Questions 135k
  • Answers 135k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Assumiung the following code for your inputs, where value is… May 12, 2026 at 6:54 am
  • Editorial Team
    Editorial Team added an answer Both Activity and Service actually extend Context so you can… May 12, 2026 at 6:54 am
  • Editorial Team
    Editorial Team added an answer You can feed the Date constructor a date in mm/dd/yyyy… May 12, 2026 at 6:54 am

Related Questions

Suppose you have the following situation #include <iostream> class Animal { public: virtual void
I'm trying to implement something like Rails dynamic-finders in Python (for webapp/GAE). The dynamic
(Django 1.x, Python 2.6.x) I have models to the tune of: class Animal(models.Model): pass
Ruby can add methods to the Number class and other core types to get

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.