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\

  1. """this is a new fuction, which work for a list"""
  2. def print_lol(the_list):
  3. """ one arguement is the_list"""
  4. for each_item in the_list:
  5. if isinstance(each_item,list):
  6. print_lol(each_item)
  7. else:
  8. print(each_item)

3. Run F5, Python解析器重置,加载了新的函数

  1. RESTART: C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester\nester.py
  2. >>> movies = ["abc","ehll","asdfdsf"]
  3. >>> print_lol(movies)
  4. abc
  5. ehll
  6. asdfdsf
  7. >>>

4. create setup.py  under C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester\

  1. from distutils.core import setup
  2.  
  3. setup(
  4. name = 'nester',
  5. version = '1.0.0',
  6. py_modules = ['nester'],
  7. author = 'eric',
  8. author_email= 'eric@126.com',
  9. url = 'http://126.com',
  10. description = 'a simple nested lists',
  11.  
  12. )

5. create distribution under CMD or Shell

  1. C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester>c:\Users\eric\AppData\Local\Programs\Python\Python35-32\python.exe setup.py sdist
  2. running sdist
  3. running check
  4. warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)
  5.  
  6. warning: sdist: standard file not found: should have one of README, README.txt
  7.  
  8. writing manifest file 'MANIFEST'
  9. creating nester-1.0.0
  10. making hard links in nester-1.0.0...
  11. hard linking nester.py -> nester-1.0.0
  12. hard linking setup.py -> nester-1.0.0
  13. creating dist
  14. creating 'dist\nester-1.0.0.zip' and adding 'nester-1.0.0' to it
  15. adding 'nester-1.0.0\nester.py'
  16. adding 'nester-1.0.0\PKG-INFO'
  17. adding 'nester-1.0.0\setup.py'
  18. removing 'nester-1.0.0' (and everything under it)

6. install nester moudle to your local

  1. C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester>c:\Users\eric\AppData\Local\Programs\Python\Python35-32\python.exe setup.py install
  2. running install
  3. running build
  4. running build_py
  5. creating build
  6. creating build\lib
  7. copying nester.py -> build\lib
  8. running install_lib
  9. copying build\lib\nester.py -> c:\Users\eric\AppData\Local\Programs\Python\Python35-32\Lib\site-packages
  10. byte-compiling c:\Users\eric\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\nester.py to nester.cpython-35.pyc
  11. running install_egg_info
  12. 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

  1. >>> import nester
  2. >>> cast = ['palin','cleese','book','jones']
  3. >>> print_lol(cast)
  4. Traceback (most recent call last):
  5. File "<pyshell#3>", line 1, in <module>
  6. print_lol(cast)
  7. NameError: name 'print_lol' is not defined
  8. >>> nester.print_lol(cast)
  9. palin
  10. cleese
  11. book
  12. jones
  13. >>>

Python 创建和发布安装函数模块的更多相关文章

  1. 【python】用setup安装自定义模块和包

    python解释器查找module进行加载的时候,查找的目录是存放在sys.path变量中的,sys.path变量中包含文件的当前目录.如果你想使用一个存放在其他目录的脚本,或者是其他系统的脚本,你可 ...

  2. Python通过pip方式安装第三方模块的两种方式

    一:环境 python3.6 windows 10 二:常用命令 如果直接执行pip命令报错,说明pip不在path环境变量中 解决方法: python -m pip list 以下默认可直接使用pi ...

  3. python在windows下安装paramiko模块和安装pycrypto模块(3步搞定)(转)

    Python中使用SSH需要用到OpenSSH,而OpenSSH依赖于paramiko模块,而paramiko模块又依赖于pycrypto模块,因此要在Python中使用SSH,我们需要先安装pycr ...

  4. Python之旅Day4 闭包函数 模块及模块倒入

    闭包函数 闭包函数就是在内部函数当中有对外部函数名字的引用 ###代码示例1### def f1(): x =1 def f2(): print(x) return f2 f=f1() f() ### ...

  5. python创建__init.py__文件导入模块仍然报错ModuleNotFoundError: No module named 'name'

    今自定义模块后非相同目录导出提示找不到模块报错信息如下: ModuleNotFoundError: No module named 'name' 各方查找各位大神方法很多 参考链接 1.在需要导入的文 ...

  6. python 读写TXT,安装pandas模块。

    今天需要用python读TXT 文件,发现pandas库好用,所以就去下载,没想pythoncharm中的setting中下载失败,所以去下源文件,安装pandas 是提示得先装numpy库,于是又去 ...

  7. 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/ 一 ...

  8. 如何卸载Python通过setup.py安装的模块

    0,pip uninstall  xxxx     1.找到egg sudo easy_install -m BitVector .... Using /usr/local/lib/python2./ ...

  9. 解决:python安装mysqldb模块报 EnvironmentError: mysql_config not found

    最近学习python操作mysql需要安装mysqldb模块 出现EnvironmentError: mysql_config not found 经网上查看,需要安装mysql客户端开发库libmy ...

随机推荐

  1. SecureCRT最佳配色方法+直接修改默认配置方法 - imsoft.cnblogs

    SecureCRT默认显示效果是黑白且刺眼的主题,看起来很不舒服.经过一番搜索,总结结果如下,直接设置默认属性,设置一次,不需再改. 效果图: 具体操作方法: Options->Global O ...

  2. win7将 esc与 capslock 互换

    一天手软,于是买了一个机械键盘.cherry g80-3494 红轴各方面都不错就是有一个问题我经常用vim,其中esc.及F键区离主键盘区实在是太远了. 习惯于vim模式的人都有一种懒症,就是手指非 ...

  3. ZOJ 1205 Martian Addition

    原题链接 题目大意:大数,20进制的加法计算. 解法:convert函数把字符串转换成数组,add函数把两个大数相加. 参考代码: #include<stdio.h> #include&l ...

  4. php部分--面向对象三大特性-封装(另加连续调用的一个例子)、继承(重写、重载的例子)、多态;

    一.封装性: 目的:为了使类更加安全. 做法:1设置私有成员 2在类中建方法,访问私有成员 3在方法里边加控制(if) 私有成员访问的两种方法: 方法一:set(可写) get(可读)做方法(可读可写 ...

  5. php使用redis存储

    一.Redis扩展模块 # wget https://codeload.github.com/phpredis/phpredis/zip/develop -O phpredis.zip # unzip ...

  6. 正确答案 全国信息学奥林匹克联赛( ( NOIP2014) 复 赛 模拟题 Day1 长乐一中

    [题目描述]小 H 与小 Y 刚刚参加完 UOIP 外卡组的初赛,就迫不及待的跑出考场对答案."吔,我的答案和你都不一样!",小 Y 说道,"我们去找神犇们问答案吧&qu ...

  7. 救援行动(save) (BFS)

    时间限制: 1 Sec  内存限制: 64 MB提交: 42  解决: 9[提交][状态][讨论版] 题目描述 Angel被人抓住关在一个迷宫了!迷宫的长.宽均不超过200,迷宫中有不可以越过的墙以及 ...

  8. hdu1058丑数(优先队列、暴力打表)

    hdu1058 题意:当一个数只有2.3.5.7这四种质因数时(也可以一种都没有或只有其中几种),这个数就是丑数,输出第 n 个丑数是多少: 其实并没有发现hdu把这道题放在 dp 专题里的意图,我的 ...

  9. Anroid 异常:is not valid; is your activity running?

    本文转载于:http://blog.csdn.net/biangren/article/details/7514722 是由于有activity时依附于另一个activity的,当被依附的activi ...

  10. Unix 入门

    说明:转自以为大神的笔记. 首先,我们一起看看UNIX的目录,因为清楚了目录,才能对UNIX的框架有个大概的印象!当然这里讲的是系统正常运转所必须的,并且一定不能删除或者修改.  / 是系统的根目录: ...