Python create a distribution for your moudle and func

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= ‘[email protected]‘,
        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
>>>
时间: 2024-11-06 22:45:16

Python create a distribution for your moudle and func的相关文章

[Python] Create a new Django project in Pycharm

From: http://blog.csdn.net/u013088062/article/details/50158239     创建新工程 1.主题 这部分教程主要介绍如何通过Pycharm创建.管理.运行一个Django工程. Django是一个开放源代码的Web应用框架,由Python写成.采用了MVC的软件设计模式,即模型M,视图V和控制器C. 2.准备工作 (1)Pycharm为3.0或者更高版本. (2)电脑上至少安装了一个Python解释器,2.4到3.3版本均可. 这部分教程

Python create a dictionary

>>> cleese={} >>> palin=dict() >>> type(cleese) <class 'dict'> >>> type(palin) <class 'dict'> >>> cleese['Name']='John Cleese' >>> cleese['Occupations']=['actor','comedian','writer','film p

Python create func

>>> movies =[ "the holy grail", 1975,"terry jones",91, ["graham chapman", ["michel palin","john cheelse","terry gilliam","eric idle","terry jones"]]] >>> def

Python a completed nested list moudle

1. update setup.py from distutils.core import setup setup( name = 'iamericnester', version = '1.4.0', py_modules = ['nester'], author = 'eric', author_email= '[email protected]', url = 'http://126.com', description = 'a simple nested lists,fix the bu

Building Python 2.7.10 with Visual Studio 2010 or 2015 - Google Chrome

您的浏览器(Chrome 33) 需要更新.该浏览器有诸多安全漏洞,无法显示本网站的所有功能.?了解如何更新浏览器 × p-nand-q.com C++? Python? Programming? Languages? Humor? Tools? Misc? Building Python 2.7.10 with Visual Studio 2010 or 2015 7th revision, August 7, 2015.A document history can be found at t

python GUI初步

打印目录内容,包括每个文件的大小和修改时间为了简单  下面的版本 只打印条目名称  而不打印它们的完整路径 TypeError:print_dir_info()missing 1 required positional argument重命名 移动 复制   删除文件rename moved copy  delett fileshutil模块 包括操作文件操作 shutil.move重命名一个函数函数shutil.move重命名一个文件 将一个文件移动到另一个目录shutil.move("old

Python 打包中 setpy.py settuptools pbr 的了解

背景 nova服务构建失败,报错: 'tests_require' must be a string or list of strings containing valid project/version requirement specifiers 概述 推荐-Python 包管理工具解惑 openstack/nova setup.py 孔令贤-关于python中的setup.py 簡單的插件框架 - 使用 pkg_resources python setup.py --help-comman

python - day06

本节课内容(___大纲___) 模块[常用模块的学习] os . sys json . pickle time . datetime random. string . join shutil shelve xml configparser hashlib [md5 .sha1 .sha256 .sha384 .sha512] logging re subprocess 模块介绍: 模块的分类: 1.标准模块 --系统自带的模块叫标准模块 2.自建模块 --自己写的模块 3.第三方模块 --别人写

python中threading模块详解(一)

python中threading模块详解(一) 来源 http://blog.chinaunix.net/uid-27571599-id-3484048.html threading提供了一个比thread模块更高层的API来提供线程的并发性.这些线程并发运行并共享内存. 下面来看threading模块的具体用法: 一.Thread的使用 目标函数可以实例化一个Thread对象,每个Thread对象代表着一个线程,可以通过start()方法,开始运行. 这里对使用多线程并发,和不适用多线程并发做