标签:
1. create dir "nester" under C:\Users\eric\AppData\Local\Programs\Python\Python35-32\
2. create a nester.py under C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester\
"""this is a new fuction, which work for a list""" def print_lol(the_list): """ one arguement is the_list""" for each_item in the_list: if isinstance(each_item,list): print_lol(each_item) else: print(each_item)
3. Run F5, Python解析器重置,加载了新的函数
RESTART: C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester\nester.py >>> movies = ["abc","ehll","asdfdsf"] >>> print_lol(movies) abc ehll asdfdsf >>>
4. create setup.py under C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester\
from distutils.core import setup setup( name = ‘nester‘, version = ‘1.0.0‘, py_modules = [‘nester‘], author = ‘eric‘, author_email= ‘eric@126.com‘, url = ‘http://126.com‘, description = ‘a simple nested lists‘, )
5. create distribution under CMD or Shell
C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester>c:\Users\eric\AppData\Local\Programs\Python\Python35-32\python.exe setup.py sdist running sdist running check warning: sdist: manifest template ‘MANIFEST.in‘ does not exist (using default file list) warning: sdist: standard file not found: should have one of README, README.txt writing manifest file ‘MANIFEST‘ creating nester-1.0.0 making hard links in nester-1.0.0... hard linking nester.py -> nester-1.0.0 hard linking setup.py -> nester-1.0.0 creating dist creating ‘dist\nester-1.0.0.zip‘ and adding ‘nester-1.0.0‘ to it adding ‘nester-1.0.0\nester.py‘ adding ‘nester-1.0.0\PKG-INFO‘ adding ‘nester-1.0.0\setup.py‘ removing ‘nester-1.0.0‘ (and everything under it)
6. install nester moudle to your local
C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester>c:\Users\eric\AppData\Local\Programs\Python\Python35-32\python.exe setup.py install running install running build running build_py creating build creating build\lib copying nester.py -> build\lib running install_lib copying build\lib\nester.py -> c:\Users\eric\AppData\Local\Programs\Python\Python35-32\Lib\site-packages byte-compiling c:\Users\eric\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\nester.py to nester.cpython-35.pyc running install_egg_info Writing c:\Users\eric\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\nester-1.0.0-py3.5.egg-info
7. import and test new moudle
>>> import nester >>> cast = [‘palin‘,‘cleese‘,‘book‘,‘jones‘] >>> print_lol(cast) Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> print_lol(cast) NameError: name ‘print_lol‘ is not defined >>> nester.print_lol(cast) palin cleese book jones >>>
Python create a distribution for your moudle and func
标签:
原文地址:http://www.cnblogs.com/oskb/p/4816929.html