After writing the module (named Nester here), put it in the same folder as the setup.py;
setup.py
from Import Setupsetup ( name=" release name, General same as module name ", Version =" release Number" ", py_modules=" Module list ", " "" parameter, additional parameters add "" "as required )
Build the publishing file: Open terminal under folder (shift+ right, select), enter: setup.py sdist
Install Publish to local copy: Continue under Terminal, enter: setup.py install
After the installation of the release will be generated under the folder Build/lib directory, the directory to save nester.py, Dist directory to save the release package, NESTER.PYC (also may be in the __pycache__ directory) is a compiled version of the Code, Manifest contains a list of files in the publication;
Functions in the module can now be used, using the first
Import Module Name
Module name. function name (parameter)//This is due to the namespace to be qualified so that the compiler can judge that the function in that namespace (there will be a function of the same name in different namespaces);
can also
From Module name Import function name//Use this method to import, add the specified function to the current namespace, so that you do not have to use namespace qualification
Function name (parameter)
The disadvantage of this method is that if the original function of the same name in the namespace is overwritten by a post-import
Python module Publishing and use