Recent Posts

Module






A module allows you to logically organize your Python code. Grouping related code into a module makes the code easier to understand and use. A module is a Python object with arbitrarily named attributes that you can bind and reference.
Simply, a module is a file consisting of Python code. A module can define functions, classes, and variables. A module can also include runnable code.
We can have our files more organized and we can reuse them as well

Example


The Python code for a module named mytransformation normally resides in a file named mytrasnaformation.py.

We will create a new module and call it transformer1, and we can call transformation1  into any program.
So first we will go to our present project, them "new file", and them choose "transformation1"



we cut it  from prueba3 and paste it in mytransformation.py



 Now we can import from 'transformation" file to "prueba3"


Now, instead of importing the entire module we can import a specific function, and after import use ctrl space


So, instead of having multiple codes, we break our code into multiple files or modules. So as you saw, you can import the entire module or just the function

Module Module Reviewed by ohhhvictor on May 13, 2019 Rating: 5

No comments:

Facebook

 photo imagen120.jpg
Theme images by 5ugarless. Powered by Blogger.