0

What does the function dir() do

Please, explain with an example

19th Mar 2020, 6:05 PM
Programmer
Programmer - avatar
1 Answer
+ 2
dir(x) will return a list of methods of x. Whether x is a module that you can import, or a class, using print(dir(itertools)) (for example) will print a list of methods within that module or class. print(dir(list)) will give you class methods you can do with lists.
19th Mar 2020, 6:18 PM
Russ
Russ - avatar