Home >>Python Built-in Functions >Python dir() Function
The dir() function in Python is an inbuilt function which returns all attributes and methods of the specified object without the value (like functions , modules, strings, lists, dictionaries etc.)
Syntax:dir(object)
Parameter | Description |
---|---|
object | It is an optional parameter object you want to see the valid attributes of |
class Person:
name = "Alex"
age = 45
country = "USA"
print(dir(Person))
class num():
def __dir__(self):
return [10,20,30]
N = num()
att = dir(N)
print(att)