Python module release and use, python module release
After writing the module (nester), put it in the same folder as setup. py;
// Setup. py
From distutils. core import setupsetup (name = "Release name, usually the same module name", version = "version", py_modules = "module list", "parameter, add "for other parameters as needed """)
Build a publishing file: Open the terminal (shift + right-click and select it) in the folder, and enter setup. py sdist.
Install and publish to local copy: continue under the terminal, enter: setup. py install
After release and installation, the build/lib directory will be generated in this folder, and the nester will be saved under the directory. py, dist directory to save the release package; nester. pyc (possibly in the _ pycache _ directory) is the compiled version code. MANIFEST contains the list of released files;
Now you can use functions in the module.
Import Module name
Module name. Function Name (parameter) // This is because you need to limit the namespace so that the compiler can determine which function is in that namespace (there will be functions with the same name in different namespaces );
Yes.
From Module name import function name // use this method to import and add a specified function to the current namespace, so you do not need to use namespace restrictions
Function Name (parameter)
// The disadvantage of this method is that if a function with the same name exists in the namespace, it will be overwritten by the later import.