dir()

A built-in function that lists the names, such as methods and attributes, available on an object or module.

In more detail

dir(str) or dir("") shows every string method. Names starting and ending with two underscores are dunder methods used by Python itself; the rest are the ones you normally call.

Example

[m for m in dir(str) if not m.startswith("_")]

Related terms

Taught in

References

Certification courses