Showing posts with the label Defining and connecting modules

Python - Defining and Connecting Modules

A Python Module is a single Python file that can be used in other Python programs.  In order to define a module, you must first create a file named *.py, which is the actual file that represents the module. The name of the file will be used as the name for the module. Then, you must define one or more function definitions in this file. Let’s say we have a main program file named and we want to connect some external modules to it.  To do that, we need to create a new module. First, we need to define a new file: a new file named in the same directory as  The Python interpreter looks for modules in several standard paths, and one of those paths is the directory where the main running Python script is located.  So, to make it easier for the interpreter, we will create both and files in the same directory.  For simplicity, we will keep both files in the same project. Create a Module Therefore, the module name will be message. In the module, let