Python Module Write and Call

python module

What Is The Module ?

The other meaning of the modules is that they are pre-made parts that are compatible with each other. These pieces come together to form a coherent whole. In the meantime, the pre-production of the modules is not personal. What is Personal is the order in which parts will be merged. Python modules. Previously written parts of the program can be included in the whole at any time. Thus, the environment in which the programmer works will not be unnecessary memory consumption from the Module User, which only works for himself. As Python contains many modules, the user can write modules himself.

We can also call Python modules as a library.

Each Python program can be a module. A module can be composed of an empty file, or it can have a complex structure with one or more classes in which some functions are written with various variables. First, let’s create a module where only a few variables are defined.

Write the codes, let’s save the file named.

When calling a module, only the file name is used (the extension is not written). The calling process is done with the import statement. Let’s call the Python interpreter and call the module we wrote before calling a different one .open the py file :

We can now access the variables in the module we wrote. If we include a module using its name in this way, the objects within the module <module>.<ObjectName> :

It’s a different one .let’s call it from the py file.


Sometimes programmers may want to call some objects in a module only with their name for convenience. To do this, you need to include only that object in the module.

from <module name> import <content object>

We should write it in the form. For example, we just need names.


If you want to use all the objects, you need to do the following:

from <module > import *


As you can see, we can use all its features by embedding the other module. This is how you should determine the calling process according to the module you are going to write.