Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Getting the class name of an instance

How do I find out the name of the class used to create an instance of an object in Python?

I'm not sure if I should use the inspect module or parse the __class__ attribute.

Answer*

Draft saved
Draft discarded
Cancel
2
  • 2
    this gives the name of a class not the class name of an instance Commented Jan 21, 2021 at 17:54
  • 1
    This was already suggested by @Dimitris in 2017 Commented Feb 16, 2023 at 22:22

lang-py

AltStyle によって変換されたページ (->オリジナル) /