1. Create a folder nester for the module nester, which contains: nester. py (module File ):
Copy codeThe Code is as follows:
"This is the" nester. py "module, which provides a function named print_lol,
The function is used to print the list. The temperament includes the nested list """
Def print_lol (the_list ):
"This function has a location parameter named" the_list ", which can be any python list.
Each data item in the specified list is recursively output to the screen, and each data item occupies a row """
For each_item in the_list:
If isinstance (each_item, list ):
Print_lol (each_item)
Else: print (each_item)
2. Create a new setup. py file (including the elements to be released) in the netster Folder ):
Copy codeThe Code is as follows:
From distutils. core import setup
Setup (name = 'nester ',
Version = '1. 0 ',
Py_modules = 'nester ',
Author = 'nididya ')
3. Build a publishing file:
In Head First Python, we talk about the release and construction of modules in Linux.
The construction module in window encountered the following problems:
Enter python in CMD to display commands that are not internal or external.
Add the python installation directory to the PATH of the system environment variable. For example, install python on C: \ Python33.
Right-click my computer icon and choose Properties> advanced> environment variables.
In the displayed dialog box, double-click the PATH line at the top and add C: \ Python33 to the variable value column. Note that the column is separated by a semicolon.
After the problem is solved, you can proceed to the steps of the release module.
Open the directory where the nester is located in the doscommand line
Cd c: \ nester I put it under the C root directory
Copy codeThe Code is as follows:
Python setup. py sdist
4. Release and install it to your python local copy
Copy codeThe Code is as follows:
Python setup. py install
After the module is released, it can be imported and used.