反向枚举

renumerate的Python项目详细描述


雷诺数

反向枚举。

概述

renumerate(序列,开始=长度(序列)-1,结束=0):

Return an enumerate object.
sequence must be an object that has a __reversed__() method or supports the
sequence protocol (the __len__() method and the __getitem__() method with
integer arguments starting at 0).
The __next__() method of the iterator returned by renumerate() returns a tuple
containing a count (from start which defaults to len(sequence) - 1 or ends at
end which defaults to 0 - but not both) and the values obtained from reverse
iterating over sequence.
>>>fromrenumerateimportrenumerate>>>seasons=['Spring','Summer','Fall','Winter']>>>list(renumerate(seasons))[(3,'Winter'),(2,'Fall'),(1,'Summer'),(0,'Spring')]>>>list(renumerate(seasons,start=4))[(4,'Winter'),(3,'Fall'),(2,'Summer'),(1,'Spring')]>>>list(renumerate(seasons,end=2))[(5,'Winter'),(4,'Fall'),(3,'Summer'),(2,'Spring')]

相当于:

defrenumerate(sequence,start=None,end=None):ifstartisnotNoneandendisnotNone:raiseTypeError("renumerate() only accepts start argument or end argument"" - not both.")ifstartisNone:start=len(sequence)-1ifendisNone:end=0n=start+endforeleminreversed(sequence):yieldn,elemn-=1

安装

先决条件:

要安装,请运行:

python -m pip install --upgrade renumerate

开发

访问development page

从源安装:

克隆sources并运行:

python -m pip install ./renumerate

或开发模式:

python -m pip install --editable ./renumerate

先决条件:

  • 开发严格基于tox。要安装它,请运行:

    python -m pip install tox
    

许可证

Copyright (c) 2016-2019 Adam Karpierz

Licensed under the zlib/libpng License
Please refer to the accompanying LICENSE file.

作者

更改日志

1.0.9(2019-05-22)

  • 放弃对python 2的支持。

1.0.8(2019-05-21)

  • 更新所需的setuptools版本。
  • 安装更新和改进。
  • 这是支持python 2的最新版本。

1.0.7(2018-11-08)

  • 放弃对Python2.6和3.0-3.3的支持
  • 更新所需的setuptools版本。

1.0.6(2018-05-08)

  • 修复描述中的错误。
  • 更新所需的setuptools版本。
  • 改进和简化安装和打包。

1.0.5(2018-02-26)

  • 改进和简化安装和打包。

1.0.4(2018-01-28)

  • 修复tox.ini中的错误和不一致性
  • 更新readme.rst。

1.0.1(2018-01-24)

  • 更新所需的sphinx版本。
  • 更新doc sphinx配置文件。

1.0.0(2017-11-18)

  • 安装改进。
  • 其他小改进。

1.0.0b1(2017-11-18)

  • 小改进。

0.3.4(2017-01-05)

  • 小的安装改进。

0.3.3(2016-09-25)

  • 修复setup.py中的错误

0.3.1(2016-09-25)

  • 更符合PEP8

0.2.2(2016-09-24)

  • 描述元素
  • 小修小修。

0.1.1(2016-09-24)

  • 第一个有用的版本。

0.0.2(2016-09-23)

  • 初次发布。

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

推荐PyPI第三方库


热门话题
Android Java在活动之间传递值   java当实体中存在关系时,我可以只使用实体的id而不是从DB中获取实体吗?   bouncycastle Java运行SSHD服务器错误未找到类定义   java SWT/Swing>Threads n'Hell   java多线程数据库读取   java如何在Eclipse中轻松提交Git   java在哪里可以找到字符串相等比较的一组特定排序规则?   无连接表的java单向单域关系   java扩展三角文件   java spring。杰克逊。序列化。failonemptybeans   java无法加载请求的类:oracle。jdbc。驾驶员OracleDriver   java通过数组进行索引循环并打印出元素?   找不到eclipse错误类中的java提交Hadoop作业   Java:随机设定种子   java片段、异步任务和侦听器   java在分号后使用{}