How to List All Functions and Attributes of a Module in Python 


               


How to List All Functions and Attributes of a Module in Python



Python


In this article, we show how to list all functions and attributes of a module in Python.

So in Python, there is a dir() method which can list all functions and attributes of a module.

Inside of this dir() function, we specify the module that we would like to see all functions and attributes of.

For example, in the following code below, we show all of the functions and attributes of the os module.



So the first thing we have to do is import the os module.

After you import the os module, then we pass the os module into the dir() function. This outputs all of the attributes and functions of the os module.

This prints out all of the attributes and functions of the os module.

You can see there are functions such as listdir, mkdir, makedirs, etc.

This creates attributes such as name, path, etc.

And this is how to list all functions, attributes, and classes of a module in Python.


Related Resources

How to Randomly Select From or Shuffle a List in Python



HTML Comment Box is loading comments...