Python module Publishing and use

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.