6. Introspection Basics
Introspection is examining objects at runtime to learn about their type and attributes.
Built-in Functions
type(obj)→ type of objectdir(obj)→ list of attributesid(obj)→ memory address (unique identifier)isinstance(obj, cls)→ type check
Example
x = [1, 2, 3]
print(type(x))
print(dir(x))
Wrap-Up
Introspection lets you explore objects dynamically, useful for debugging and frameworks.