CKTIS / Python
type.__name__
This class attribute gives the simple type name without its module or enclosing classes.
Version: Python 3.14; repository image, production runtime not attested
Syntax
name = type(value).__name__This class attribute gives the simple type name without its module or enclosing classes.
type.__name__
The qualified __qualname__ retains nesting. Distinct types can share a simple name. Changing a user-defined class's name string does not change class identity.
The first print distinguishes Item from Outer.Item, followed by Entry True after renaming.
class One:
class Item: pass
class Two:
class Item: pass
assert One.Item.__name__==Two.Item.__name__ and One.Item is not Two.Item
try: One.Item.__name__=3
except TypeError: pass
else: raise AssertionError
Examples
class Outer:
class Item: pass
item=Outer.Item()
print(type(item).__name__, type(item).__qualname__)
Outer.Item.__name__="Entry"
print(type(item).__name__, Outer.Item is type(item))
Result
Item Outer.Item Entry True
The first print distinguishes Item from Outer.Item, followed by Entry True after renaming.