Skip to content

help() and dir()

Python provides help() and dir() as introspection tools: help() displays an object's documentation, while dir() lists its available attributes and methods.

help()

Displays the built-in documentation for any Python object, including functions, modules, and classes.

help(print)

dir()

Lists all attributes and methods available on a given object or type.

dir(str)

Example output:

['capitalize','count','encode','find','lower']

Practical Example

x = "Python"

print(dir(x))

These tools help developers discover available functionality.