__qualname__ — Easy Examples
Qualified name of a class or function (includes enclosing scope)
Accessing __qualname__
How to access and use __qualname__.
python
# __qualname__ holds the qualified name class Outer: class Inner: def method(self): pass print(Outer.__qualname__) print(Outer.Inner.__qualname__) print(Outer.Inner.method.__qualname__)
__qualname__ is a special attribute that qualified name of a class or function (includes enclosing scope).
__qualname__ in practice
Using __qualname__ in everyday code.
python
# More __qualname__ examples print("__qualname__ is a special Python attribute") # Every object has certain dunder attributes obj = object() attrs = [a for a in dir(obj) if a.startswith("__")] print(f"object has {len(attrs)} dunder attributes")
Understanding __qualname__ helps you introspect and debug Python objects.
Want to try these examples interactively?
Open Easy Playground