dir() — Easy Examples
Lists the names (attributes and methods) of an object or current scope
Basic dir() usage
Simple demonstration of the dir() built-in function.
python
print(dir(int)[:5]) print(dir(str)[:5])
dir() is a built-in function that lists the names (attributes and methods) of an object or current scope.
dir() with different inputs
Calling dir() with various argument types.
python
# More dir() examples print("dir() is a Python built-in function") print(f"Type: {type(dir)}")
dir() accepts different types of arguments and produces corresponding results.
Want to try these examples interactively?
Open Easy Playground