Listing the contents of an imported module

The names inside a module might include value assignments, other modules that the module imports, functions, classes, and so on.

To see the names that belong to a module you've imported—either a .py file you wrote yourself or one of Python's modules—type dir() with the name of the module inside the parentheses. For example, to import the math module that comes with Python and list its functions, follow these steps:

1. At the Python prompt, type import math.

Was this article helpful?

0 0

Post a comment