How to get object name? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to get object name? (/thread-17938.html) |
How to get object name? - bhojendra - Apr-30-2019 When I print obj it prints something like: print(type(obj)) # <class 'some.third.party.ObjectName'>What I want here is to print ObjectName . How can I get it?
RE: How to get object name? - buran - Apr-30-2019 class Foo: class Bar: pass foo = Foo() bar = Foo.Bar() print(foo.__class__.__name__) print(foo.__class__.__qualname__) print(bar.__class__.__name__) print(bar.__class__.__qualname__)
RE: How to get object name? - bhojendra - Apr-30-2019 __qualname__ is what I want. Thanks.
|