Sometimes you work with a Python module and does not have good documentation about it (or do not have it at all). In this short How To, you’ll see how to get the most information possible from a Python module, as the list of features or attributes eg.
Get the list of the functions and attributes of a Python module
First, you need to import the module
Then, you can use the dir() function to get a complete list of attributes and functions of a Python module
It returns a list of all the functions and attributes of the module.
Also if you want to get specific information for each of these functions, you can use the help() function.
import seolib dir(seolib)
Here is the list with all functions
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__title__', '__version__', 'api', 'decorators', 'errors', 'get_alexa', 'get_facebook_likes', 'get_google_plus', 'get_semrush', 'get_seomoz_data', 'get_tweets', 'helpers']
Finally if you want to know more detailed information, for example, about get_facebook_likes() function.
help(seolib.get_facebook_likes()) Help on function wrapper in module seolib.decorators: wrapper(url, *args, **kwargs)
Among the functions and attributes found in the example above list there are some attributes worth mentioning. In fact there are a number of attributes that are generated by Python automatically when you create a new form. These attributes can be useful to obtain more information.
This attribute contains all attributes built-in that are accessible by the module.
This attribute gives you the name and location of the cached files associated with the module. The path is relative to the current directory of Python.
This attribute gives you the name and location of the form file. The path is relative to the current directory of Python
This attribute displays the module information, always assuming that the developer has ever entered them.
It determines whether the module is in the initialization phase. Generally, this value is always False, however, is useful in scripting when you want to ensure that a module has been fully imported (and initialized) before making any other particular operation (import a module that depends on it)
This attribute shows the loader information for this module. The loader takes care of the just loaded module and puts it in memory so that Python can use it.
It contains the module name
This attribute is used by the system to load and manage internally the module[:]