Chapters
Python114 chapters

ReferenceBuilt-in functions

dir()

Lists the names defined on an object, which is how you explore an unfamiliar one.

Signature

dir(object)

Parameters

NameMeans
objectany object; with no argument, the current scope

Returns

A sorted list of attribute names.

Example

Python
print("upper" in dir(str))
print(len(dir(list)) > 10)

Output

True
True

See also