Python Custom Modules
How to make your own custom module
This is in Python!
So let's make a module in Python!
What is a Module?
A module is a something like a package. Here is an example. Imagine coding in Python is like making something with Lego,
then Modules are boxes you can import and they contain special building blocks, attributes, ones which do not come in the normal lego sets.
This is an example:
I want to print a random integer from 1 to 10 in Python. Without modules, it is impossible to do so. So we use the 'random' module :
So this is a Module. How do we make one?
These Modules need to be in a separate file and to use them in other py projects, you need to copy the file
When you start, make a new file. We will call this "module_custom.py", now go to "main.py" and do this:
Now go to the "module_custom.py" and write lot's of functions (these will become attributes)! For example, I am only doing a module with 1 attribute.
See? We put the module name, then a dot, then the attribute name and then the value. It is also the same in the custom
And there you go! A module! When using it in other projects, make a new file and copy paste the code and then import it!