A class’s `__name__` attribute contains its defining name. If you have an instance rather than the class, first retrieve the class through the instance’s `__class__` attribute. section 17.3
Get a class name from an instance
```python class A: pass class B(A): pass b = B() b.__class__.__name__ # 'B' ``` The class object is also available as `B`; its `__bases__` attribute gives the base classes. Together, these attributes let you inspect an instance’s class and inheritance structure. section 17.3
Do not confuse a class’s `__name__` attribute with the module-level `__name__` variable. The latter is `'__main__'` when a file runs as a script and its module name when imported; it is commonly used to guard a call to `main()`. For ordinary type checks, `isinstance()` or `issubclass()` is usually more convenient than inspecting class attributes. section 11.1.3 section 17.3

