如果参数为None,则返回默认值

lib-parameter的Python项目详细描述


lib_参数

版本v1.1.8自2020-10-09起参见Changelog

travis_buildlicensejupyterpypi

codecovbetter_codeMaintainabilityMaintainabilityCode Coveragesnyk

如果参数为None,则返回默认值

对于mypy类型注释,参数的类型通常为Optional[T],返回的类型为T

真的不值得一个包裹,只是不知道该放在哪里。在

# definitionfromtypingimportTypeVar,OptionalT=TypeVar('T')defget_default_if_none(parameter:Optional[T],default:T)->T:ifparameterisNone:returndefaultelse:returnparameter
^{pr2}$ 自动化测试、Travis矩阵、文档、徽章等由PizzaCutter(类固醇cookiecutter)管理

需要Python版本:3.6.0或更高版本

使用python3.6、3.7、3.8、3.9-dev、pypy3在linux“仿生”上进行测试-体系结构:amd64、ppc64le、s390x、arm64

100% code coverage,flake8样式检查,mypy静态类型检查,在Linux, macOS, Windows下测试,自动每日构建和监视

  • Try it Online
  • Usage
  • Usage from Commandline
  • Installation and Upgrade
  • Requirements
  • Acknowledgements
  • Contribute
  • Report Issues
  • Pull Request
  • Code of Conduct
  • License
  • Changelog
  • 在线试用

    您可以使用“启动活页夹”徽章在Jupyter笔记本中立即尝试,或单击here

    用法

    import the module and check the code - its easy and documented there, including doctest examples.
    in case of any questions the usage section might be expanded at a later time
    

    命令行的用法

    Usage: lib_parameter [OPTIONS] COMMAND [ARGS]...
    
      small gist,to return a default value if the parameter is None
    
    Options:
      --version                     Show the version and exit.
      --traceback / --no-traceback  return traceback information on cli
      -h, --help                    Show this message and exit.
    
    Commands:
      info  get program informations
    

    安装和升级

    • 在开始之前,强烈建议您更新pip和设置工具:
    python -m pip --upgrade pip
    python -m pip --upgrade setuptools
    
    • 要通过pip从PyPi安装最新版本(推荐):
    python -m pip install --upgrade lib_parameter
    
    • 要通过pip从github安装最新版本:
    python -m pip install --upgrade git+https://github.com/bitranox/lib_parameter.git
    
    • 包括在你的要求.txt公司名称:
    # Insert following line in Your requirements.txt:
    # for the latest Release on pypi:
    lib_parameter
    
    # for the latest development version :
    lib_parameter @ git+https://github.com/bitranox/lib_parameter.git
    
    # to install and upgrade all modules mentioned in requirements.txt:
    python -m pip install --upgrade -r /<path>/requirements.txt
    
    • 要从源代码安装最新的开发版本:
    # cd ~
    $ git clone https://github.com/bitranox/lib_parameter.git
    $ cd lib_parameter
    python setup.py install
    
    • 通过生成文件: makefile是一种非常方便的安装方式。在这里我们可以做得更多, 比如安装虚拟环境、清理缓存等等。在
    # from Your shell's homedirectory:
    $ git clone https://github.com/bitranox/lib_parameter.git
    $ cd lib_parameter
    
    # to run the tests:
    $ make test# to install the package
    $ make install
    
    # to clean the package
    $ make clean
    
    # uninstall the package
    $ make uninstall
    

    要求

    将自动安装以下模块:

    ## Project Requirements
    click
    cli_exit_tools @ git+https://github.com/bitranox/cli_exit_tools.git
    

    致谢

    • 特别感谢“鲍勃叔叔”罗伯特·C·马丁,特别是他关于“干净代码”和“干净架构”的书

    贡献

    我很乐意为你叉和发送我的请求,为这个项目。 -please Contribute

    许可证

    此软件是按MIT license授权的

    -

    {id10}$

    变更日志

    • 新API的主要版本更改不兼容
    • 新的次要版本,以向后兼容的方式添加了功能
    • 新的补丁版本,用于向后兼容的错误修复

    v1.1.8

    2020-10-09:服务发布
    • 更新travis build matrix for linux 3.9-dev
    • 为windows 3.9/3.10更新travis构建矩阵(路径)

    v1.1.7

    2020-08-08:服务发布
    • 修复文档
    • 修理特拉维斯
    • 不推荐pycodestyle
    • 机具薄片8

    v1.1.6

    2020-08-07:固定车轮

    v1.1.5

    2020-08-01:修复pypi部署

    v1.1.4

    2020年7月31日:首次发布PyPi

    欢迎加入QQ群-->: 979659372 Python中文网_新手群

    推荐PyPI第三方库


    热门话题
    graph Java自己生成类图   java MouseMotionListener:鼠标和触控板给出不同的结果   java解析清单条目的正确方法是什么。jar中的mf文件?   java如何创建带有半透明色块的透明gif/png图像?   java应用内计费V3:跨设备同步购买   java Spring数据JPA注入失败BeanCreationException:无法自动连接字段   Java数据结构维护插入顺序和重复值   java无法在VSCode中设置JavaFX   java中数据字段初始化的类顺序   java如何使用ClientBuilder为Rest Post Api多部分编写集成测试   JUnit测试divide()方法的java正确方法   java将消息标记为接收前已读   Java ArrayList调用扩展对象函数   java Android:只使用GCM的TCP/IPServer   Java如何将xls数据转换为txt文件   编译为Jar文件后未找到java类   java返回子字符串的所有匹配项   java Get json用户_timeline api twitter 1.1