Python Modules

In Python, a module is simply a file with the .py extension that contains Python code. Python modules are imported into other Python modules using the import or from keywords. Importing modules makes the objects in those modules accessible to the module doing the import.

Example

Let's say you have a file called "myModule.py" that looks like this:

Python
class ExportedClass():
    def sayHello(self):
        print('hello')

the module name is "myModule" which can be used like this:

Python
import myModule
object = myModule.ExportedClass()
object.sayHello()

Output

Hello