iNTERFACEWARE Products Manual > Learning Center > Learning Python > Modules |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
In Python, a module is a file containing a collection of functions and variables. This collection can be referenced by other Python programs. Modules are a convenient way to create reusable code to handle commonly performed tasks. To create a module, all you need to do is create a file containing the functions and variables that you want to include in the module. For example, suppose that you want to create a module called temperature that contains functions to convert temperature readings in Fahrenheit to Celsius, and vice versa. Here are some sample functions that perform these conversions:
To create a module named temperature that contains these functions, you need to:
Note that the name of the module always matches the name of the file. Modules always have a suffix of .py.
The following sections provide more information on modules: |