Python notes (iii): Building a publishing module

Source: Internet
Author: User

(i) preparatory work

    1. 1. Create a new module (name customization) that holds the module code to be published.
    2. 2. Create a new setup.py module (storing the metadata of the module, describing the relevant information).
    3. 3. Create a new folder (the name matches the name of the module you want to publish), and then put the above 2 modules in a folder.

For example, I create a module disposelist.py that processes list data, and the code is as follows:

# Create a function to process the list
def Print_li (the_list):
for UE in The_list:
# determine if the data type is a list
if isinstance (UE, list):
PRINT_LI (UE)
Else:
PRINT (UE)

Create a setup.py module with the following code:

Setup
# Import the Setup function from the Python publishing tool

Setup
' Disposelist ',
' 1.0.0 ',
# Correlation Module
Py_modules =[' disposelist '],
' Lqh ',
author_email=' [email protected] ',
Url=' 1 ',
' Process List Data '
)

Create a folder Disposelist, copy the above 2 modules to the folder, OK, the pre-work is complete.

(ii) CMD Input in python setup.py sdist Publish the module (instead of opening the command window directly under the folder, add setup.py 's path). After the publication is successful, you can share your modules with others.

(iii) CMD input sudo python setup.py install Install the module to Python in the local copy ( .. \python36\lib\site-packages, add to this directory).

can be used after successful installation Import Import

Cannot import, as shown, replace the Python.exe with your own installation directory.

Python notes (iii): Building a publishing module

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.