[Solved] how to make this code to become module


According to the docs, a module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended.

You can import modules by simply using import moduleNameHere.

Your problem could be that you want to create a package, not a module. Again, according to the docs, packages are a way of structuring Python’s module namespace by using “dotted module names”. For example, the module name A.B designates a submodule named B in a package named A. Just like the use of modules saves the authors of different modules from having to worry about each other’s global variable names, the use of dotted module names saves the authors of multi-module packages like NumPy or the Python Imaging Library from having to worry about each other’s module names.

The simplest way to create a package, is to create a file named __init__.py in the same directory as the script you want to package.

You can check out this answer for more details. But basically if you want a package called hellostackoverflow, you should have a directory structure like this one:

.
└── hellostackoverflow/
    ├── __init__.py
    └── hellostackoverflow.py

Good luck!

solved how to make this code to become module