InterviewSolution
Saved Bookmarks
| 1. |
What is the use of dir () function in Python? |
|
Answer» In Python, the DIR() function is used to return all the properties and methods within a specified object, without actually having the VALUES. The dir() function shall return all the features and methods present, INCLUDING the in-built properties, which are set as default for all the objects within. ExampleHere’s a SHORT example to demonstrate the dir() function in Python: class Person: print(dir(Person)) Output ['__doc__', '__module__', 'age', 'country', 'name'] |
|