Python module release and use, python module release

Source: Internet
Author: User

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.

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.