zoukankan      html  css  js  c++  java
  • Python 创建和发布安装函数模块

    1. create dir "nester" under C:UsersericAppDataLocalProgramsPythonPython35-32

    2. create a nester.py under C:UsersericAppDataLocalProgramsPythonPython35-32 ester

    """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:UsersericAppDataLocalProgramsPythonPython35-32
    ester
    ester.py 
    >>> movies = ["abc","ehll","asdfdsf"]
    >>> print_lol(movies)
    abc
    ehll
    asdfdsf
    >>> 
    

    4. create setup.py  under C:UsersericAppDataLocalProgramsPythonPython35-32 ester

    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:UsersericAppDataLocalProgramsPythonPython35-32
    ester>c:UsersericAppDataLocalProgramsPythonPython35-32python.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
    ester-1.0.0.zip' and adding 'nester-1.0.0' to it
    adding 'nester-1.0.0
    ester.py'
    adding 'nester-1.0.0PKG-INFO'
    adding 'nester-1.0.0setup.py'
    removing 'nester-1.0.0' (and everything under it)
    

    6. install nester moudle to your local

    C:UsersericAppDataLocalProgramsPythonPython35-32
    ester>c:UsersericAppDataLocalProgramsPythonPython35-32python.exe setup.py install
    running install
    running build
    running build_py
    creating build
    creating buildlib
    copying nester.py -> buildlib
    running install_lib
    copying buildlib
    ester.py -> c:UsersericAppDataLocalProgramsPythonPython35-32Libsite-packages
    byte-compiling c:UsersericAppDataLocalProgramsPythonPython35-32Libsite-packages
    ester.py to nester.cpython-35.pyc
    running install_egg_info
    Writing c:UsersericAppDataLocalProgramsPythonPython35-32Libsite-packages
    ester-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
    >>>
    
  • 相关阅读:
    索引跳跃式扫描(INDEX SKIP SCAN)
    Oracle参数Arraysize设置对于逻辑读的影响分析
    Oracle的SQL优化思路
    通过SID查找历史执行的SQL语句
    expdp/impdp数据泵分区表导入太慢了。添加不检查元数据参数提高效率:ACCESS_METHOD=DIRECT_PATH
    Oracle不能并行直接添加主键的方法:先建唯一索引后建主键
    ORA-20011 问题处理
    安装grid时找不到ASM共享磁盘
    jmeter-测试计划
    jmeter解压后启动jmeter.bat报错:Not able to find java executable or version
  • 原文地址:https://www.cnblogs.com/oskb/p/4816929.html
Copyright © 2011-2022 走看看