Python 创建和发布安装函数模块
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 创建和发布安装函数模块的更多相关文章
- 【python】用setup安装自定义模块和包
python解释器查找module进行加载的时候,查找的目录是存放在sys.path变量中的,sys.path变量中包含文件的当前目录.如果你想使用一个存放在其他目录的脚本,或者是其他系统的脚本,你可 ...
- Python通过pip方式安装第三方模块的两种方式
一:环境 python3.6 windows 10 二:常用命令 如果直接执行pip命令报错,说明pip不在path环境变量中 解决方法: python -m pip list 以下默认可直接使用pi ...
- python在windows下安装paramiko模块和安装pycrypto模块(3步搞定)(转)
Python中使用SSH需要用到OpenSSH,而OpenSSH依赖于paramiko模块,而paramiko模块又依赖于pycrypto模块,因此要在Python中使用SSH,我们需要先安装pycr ...
- Python之旅Day4 闭包函数 模块及模块倒入
闭包函数 闭包函数就是在内部函数当中有对外部函数名字的引用 ###代码示例1### def f1(): x =1 def f2(): print(x) return f2 f=f1() f() ### ...
- python创建__init.py__文件导入模块仍然报错ModuleNotFoundError: No module named 'name'
今自定义模块后非相同目录导出提示找不到模块报错信息如下: ModuleNotFoundError: No module named 'name' 各方查找各位大神方法很多 参考链接 1.在需要导入的文 ...
- python 读写TXT,安装pandas模块。
今天需要用python读TXT 文件,发现pandas库好用,所以就去下载,没想pythoncharm中的setting中下载失败,所以去下源文件,安装pandas 是提示得先装numpy库,于是又去 ...
- Python 2.7.6 安装lxml模块[ubuntu14.04 LTS]
lxml --->首字母是字母l,不是数字1 lxml 2.x : https://pypi.python.org/pypi/lxml/2.3 1xml官网:http://lxml.de/ 一 ...
- 如何卸载Python通过setup.py安装的模块
0,pip uninstall xxxx 1.找到egg sudo easy_install -m BitVector .... Using /usr/local/lib/python2./ ...
- 解决:python安装mysqldb模块报 EnvironmentError: mysql_config not found
最近学习python操作mysql需要安装mysqldb模块 出现EnvironmentError: mysql_config not found 经网上查看,需要安装mysql客户端开发库libmy ...
随机推荐
- href="#"与javascript:void(0)的区别
共同点:都是一个空链接. 不同点:所以,#与javascript:void(0)的区别也很明显,#方法会跳转到页面的顶部,并且在页面URL后面会出现#,而javascript:void(0)方法不会, ...
- css透明度的设置 (兼容所有浏览器)
一句话搞定透明背景! .transparent_class { filter:alpha(opacity=); -moz-opacity:0.5; -khtml-opacity: 0.5; opaci ...
- PHP部分---字符串处理(文中例子不断更新);
字符串处理: 1.去除 ltrim(),rtrim()函数 trim()函数 trim(字符串名)函数:--去掉字符串两边的空格 ltrim(字符串名,“特殊字符”);--去除字符串左边的空格和 ...
- php随笔杂记(一)
1.在function updatepwd($postData=array()) 如果参数是一个数组, 在使用时,如果给他赋值则只返回数组名$postData即可 ,如果里面已有值 ,这返回的可 ...
- JsonModelStrategy策略添加
今天在学习 zf2的时候,发现后端如果返回的是JsonModel的话,则在前台异步请求的时候发现取不到数据了,后来经过多次研究,才发现要在view_manager中创建策略,代ma是这样子的,stra ...
- 越狱Season 1-Episode 17: J-Cat
Season 1, Episode 17: J-Cat -Pope: Hey, that's looking good. 嗨,看起来真棒 You're making some real progres ...
- click 绑定(三)防止事件冒泡
防止事件冒泡 默认情况下,Knockout允许click事件继续在更高一层的事件句柄上冒泡执行.例如,如果你的元素和父元素都绑定了click事件,那当你点击该元素的时候两个事件都会触发的.如果需要, ...
- Java设计模式之简单工厂设计模式
简单工厂将业务逻辑部分和界面逻辑部分分离开来,降低了界面逻辑和业务逻辑的耦合度,符合面向对象迪米特法则.下面以一个加法减法运算器为例,各位读者可以自行按照这种设计方式设计出一个小小的运算器. 1.业务 ...
- sersync2 实时同步配置
在同步服务器上开启sersync,将监控路径中的文件同步到目标服务器,因此需要在同步服务器配置sersync,在同步目标服务器配置rsync. 一.同步目标服务器配置rsync # rpm -qa | ...
- Linux-内核缓存区和write行为
<Unix环境高级编程> 应用缓冲技术能很明显的提高系统效率.内核与外围设备的数据交换,内核与用户空间的数据交换都是比较费时的,使用缓冲区就是为了优化这些费时的操作.其实核心到用户空间的操 ...