Creating and using a Python module

Let’s get clear what a module is.A module is a Python file that contains pre-built functions. Now,  to creat a module we have to creat a file with the extension “.py”,(that represen tha the file is a file python),and save it on the main folder of python.The direction of this folder can be found on C:Python34.

In this file you can create as many functions as you want after you’ve create’d your function you saved. So now that your functions are in you module and your module is in your main folder of python, you can use it, writing “import” followed the name of the module. But that is not all, with “import” you open the module but now you have to choose which fuction you are going to use. You have to write the name of the module, point, the name of the function and in parentheses the variable to which we want to apply the function. Here is a very simple example to help you understand better this

CC BY 4.0 Creating and using a Python module by Jorge Padilla is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.