renumerate


Namerenumerate JSON
Version 1.2.2 PyPI version JSON
download
home_pageNone
SummaryReverse enumerate.
upload_time2024-11-05 15:51:12
maintainerAdam Karpierz
docs_urlNone
authorAdam Karpierz
requires_python<4.0.0,>=3.9.0
licensezlib/libpng License ; https://opensource.org/license/zlib
keywords renumerate enumerate
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            renumerate
==========

Reverse enumerate.

Overview
========

**renumerate(sequence, start=len(sequence)-1, end=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*.

`PyPI record`_.

`Documentation`_.

Usage
-----

.. code:: python

  >>> from renumerate import renumerate
  >>> 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')]

Equivalent to:

.. code:: python

  def renumerate(sequence, start=None, end=None):
      if start is not None and end is not None:
          raise TypeError("renumerate() only accepts start argument or end argument"
                          " - not both.")
      if start is None: start = len(sequence) - 1
      if end   is None: end   = 0
      n = start + end
      for elem in reversed(sequence):
          yield n, elem
          n -= 1

Installation
============

Prerequisites:

+ Python 3.9 or higher

  * https://www.python.org/

+ pip and setuptools

  * https://pypi.org/project/pip/
  * https://pypi.org/project/setuptools/

To install run:

  .. parsed-literal::

    python -m pip install --upgrade |package|

Development
===========

Prerequisites:

+ Development is strictly based on *tox*. To install it run::

    python -m pip install --upgrade tox

Visit `Development page`_.

Installation from sources:

clone the sources:

  .. parsed-literal::

    git clone |respository| |package|

and run:

  .. parsed-literal::

    python -m pip install ./|package|

or on development mode:

  .. parsed-literal::

    python -m pip install --editable ./|package|

License
=======

  | |copyright|
  | Licensed under the zlib/libpng License
  | https://opensource.org/license/zlib
  | Please refer to the accompanying LICENSE file.

Authors
=======

* Adam Karpierz <adam@karpierz.net>

.. |package| replace:: renumerate
.. |package_bold| replace:: **renumerate**
.. |copyright| replace:: Copyright (c) 2016-2024 Adam Karpierz
.. |respository| replace:: https://github.com/karpierz/renumerate.git
.. _Development page: https://github.com/karpierz/renumerate
.. _PyPI record: https://pypi.org/project/renumerate/
.. _Documentation: https://renumerate.readthedocs.io/
.. _enumerate: https://docs.python.org/library/functions.html#enumerate

Changelog
=========

1.2.2 (2024-10-30)
------------------
- Setup (dependencies) update.

1.2.1 (2024-10-09)
------------------
- Setup (dependencies) update.

1.2.0 (2024-09-30)
------------------
- Drop support for Python 3.8
- Setup (dependencies) update.

1.1.14 (2024-08-13)
-------------------
- Add support for Python 3.13
- Setup (dependencies) update.

1.1.13 (2024-07-15)
-------------------
- Setup (dependencies) update.

1.1.12 (2024-01-26)
-------------------
- Setup update (now based on tox >= 4.0).
- Cleanup.

1.1.10 (2022-10-18)
-------------------
- Tox configuration has been moved to pyproject.toml

1.1.9 (2022-08-22)
------------------
- Setup update.

1.1.8 (2022-07-24)
------------------
- Add support for Python 3.10 and 3.11
- Setup update (currently based mainly on pyproject.toml).

1.1.7 (2022-01-10)
------------------
- Drop support for Python 3.6.
- Copyright year update.
- Setup update.

1.1.6 (2021-12-11)
------------------
- Setup update.

1.1.5 (2021-07-20)
------------------
- Setup general update and improvement.

1.1.4 (2020-10-18)
------------------
- Drop support for Python 3.5.
- Add unittests.
- Fixed docs setup.

1.0.13 (2020-09-22)
-------------------
- Add support for Python 3.8 and 3.9.
- Drop support for Python 3.4.
- Setup: fix an improper dependencies versions.
- Setup general update and cleanup.

1.0.9 (2019-05-22)
------------------
- Drop support for Python 2.

1.0.8 (2019-05-21)
------------------
- Update required setuptools version.
- Setup update and improvements.
- This is the latest release that supports Python 2.

1.0.7 (2018-11-08)
------------------
- Drop support for Python 2.6 and 3.0-3.3.
- Update required setuptools version.

1.0.6 (2018-05-08)
------------------
- Fix a bug in description.
- Update required setuptools version.
- Improve and simplify setup and packaging.

1.0.5 (2018-02-26)
------------------
- Improve and simplify setup and packaging.

1.0.4 (2018-01-28)
------------------
- Fix a bug and inconsistencies in tox.ini
- Update of README.rst.

1.0.1 (2018-01-24)
------------------
- Update required Sphinx version.
- Update doc Sphinx configuration files.

1.0.0 (2017-11-18)
------------------
- Setup improvements.
- Other minor improvements.

1.0.0b1 (2017-11-18)
--------------------
- Minor improvements.

0.3.4 (2017-01-05)
------------------
- Minor setup improvements.

0.3.3 (2016-09-25)
------------------
- Fix bug in setup.py

0.3.1 (2016-09-25)
------------------
- More PEP8 compliant.

0.2.2 (2016-09-24)
------------------
- Description suplement
- Minor fixes.

0.1.1 (2016-09-24)
------------------
- First useful release.

0.0.2 (2016-09-23)
------------------
- Initial release.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "renumerate",
    "maintainer": "Adam Karpierz",
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.9.0",
    "maintainer_email": "adam@karpierz.net",
    "keywords": "renumerate, enumerate",
    "author": "Adam Karpierz",
    "author_email": "adam@karpierz.net",
    "download_url": "https://files.pythonhosted.org/packages/63/43/e3ba26782bfc3b49fe58ad46a208548a59840086843c96a3e427ddc86e05/renumerate-1.2.2.zip",
    "platform": "any",
    "description": "renumerate\r\n==========\r\n\r\nReverse enumerate.\r\n\r\nOverview\r\n========\r\n\r\n**renumerate(sequence, start=len(sequence)-1, end=0):**\r\n\r\n| Return an enumerate_ object.\r\n| *sequence* must be an object that has a __reversed__() method or supports the\r\n  sequence protocol (the __len__() method and the __getitem__() method with\r\n  integer arguments starting at 0).\r\n| The __next__() method of the iterator returned by renumerate() returns a tuple\r\n  containing a count (from *start* which defaults to len(*sequence*) - 1 or ends at\r\n  *end* which defaults to 0 - but not both) and the values obtained from reverse\r\n  iterating over *sequence*.\r\n\r\n`PyPI record`_.\r\n\r\n`Documentation`_.\r\n\r\nUsage\r\n-----\r\n\r\n.. code:: python\r\n\r\n  >>> from renumerate import renumerate\r\n  >>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']\r\n  >>> list(renumerate(seasons))\r\n  [(3, 'Winter'), (2, 'Fall'), (1, 'Summer'), (0, 'Spring')]\r\n  >>> list(renumerate(seasons, start=4))\r\n  [(4, 'Winter'), (3, 'Fall'), (2, 'Summer'), (1, 'Spring')]\r\n  >>> list(renumerate(seasons, end=2))\r\n  [(5, 'Winter'), (4, 'Fall'), (3, 'Summer'), (2, 'Spring')]\r\n\r\nEquivalent to:\r\n\r\n.. code:: python\r\n\r\n  def renumerate(sequence, start=None, end=None):\r\n      if start is not None and end is not None:\r\n          raise TypeError(\"renumerate() only accepts start argument or end argument\"\r\n                          \" - not both.\")\r\n      if start is None: start = len(sequence) - 1\r\n      if end   is None: end   = 0\r\n      n = start + end\r\n      for elem in reversed(sequence):\r\n          yield n, elem\r\n          n -= 1\r\n\r\nInstallation\r\n============\r\n\r\nPrerequisites:\r\n\r\n+ Python 3.9 or higher\r\n\r\n  * https://www.python.org/\r\n\r\n+ pip and setuptools\r\n\r\n  * https://pypi.org/project/pip/\r\n  * https://pypi.org/project/setuptools/\r\n\r\nTo install run:\r\n\r\n  .. parsed-literal::\r\n\r\n    python -m pip install --upgrade |package|\r\n\r\nDevelopment\r\n===========\r\n\r\nPrerequisites:\r\n\r\n+ Development is strictly based on *tox*. To install it run::\r\n\r\n    python -m pip install --upgrade tox\r\n\r\nVisit `Development page`_.\r\n\r\nInstallation from sources:\r\n\r\nclone the sources:\r\n\r\n  .. parsed-literal::\r\n\r\n    git clone |respository| |package|\r\n\r\nand run:\r\n\r\n  .. parsed-literal::\r\n\r\n    python -m pip install ./|package|\r\n\r\nor on development mode:\r\n\r\n  .. parsed-literal::\r\n\r\n    python -m pip install --editable ./|package|\r\n\r\nLicense\r\n=======\r\n\r\n  | |copyright|\r\n  | Licensed under the zlib/libpng License\r\n  | https://opensource.org/license/zlib\r\n  | Please refer to the accompanying LICENSE file.\r\n\r\nAuthors\r\n=======\r\n\r\n* Adam Karpierz <adam@karpierz.net>\r\n\r\n.. |package| replace:: renumerate\r\n.. |package_bold| replace:: **renumerate**\r\n.. |copyright| replace:: Copyright (c) 2016-2024 Adam Karpierz\r\n.. |respository| replace:: https://github.com/karpierz/renumerate.git\r\n.. _Development page: https://github.com/karpierz/renumerate\r\n.. _PyPI record: https://pypi.org/project/renumerate/\r\n.. _Documentation: https://renumerate.readthedocs.io/\r\n.. _enumerate: https://docs.python.org/library/functions.html#enumerate\r\n\r\nChangelog\r\n=========\r\n\r\n1.2.2 (2024-10-30)\r\n------------------\r\n- Setup (dependencies) update.\r\n\r\n1.2.1 (2024-10-09)\r\n------------------\r\n- Setup (dependencies) update.\r\n\r\n1.2.0 (2024-09-30)\r\n------------------\r\n- Drop support for Python 3.8\r\n- Setup (dependencies) update.\r\n\r\n1.1.14 (2024-08-13)\r\n-------------------\r\n- Add support for Python 3.13\r\n- Setup (dependencies) update.\r\n\r\n1.1.13 (2024-07-15)\r\n-------------------\r\n- Setup (dependencies) update.\r\n\r\n1.1.12 (2024-01-26)\r\n-------------------\r\n- Setup update (now based on tox >= 4.0).\r\n- Cleanup.\r\n\r\n1.1.10 (2022-10-18)\r\n-------------------\r\n- Tox configuration has been moved to pyproject.toml\r\n\r\n1.1.9 (2022-08-22)\r\n------------------\r\n- Setup update.\r\n\r\n1.1.8 (2022-07-24)\r\n------------------\r\n- Add support for Python 3.10 and 3.11\r\n- Setup update (currently based mainly on pyproject.toml).\r\n\r\n1.1.7 (2022-01-10)\r\n------------------\r\n- Drop support for Python 3.6.\r\n- Copyright year update.\r\n- Setup update.\r\n\r\n1.1.6 (2021-12-11)\r\n------------------\r\n- Setup update.\r\n\r\n1.1.5 (2021-07-20)\r\n------------------\r\n- Setup general update and improvement.\r\n\r\n1.1.4 (2020-10-18)\r\n------------------\r\n- Drop support for Python 3.5.\r\n- Add unittests.\r\n- Fixed docs setup.\r\n\r\n1.0.13 (2020-09-22)\r\n-------------------\r\n- Add support for Python 3.8 and 3.9.\r\n- Drop support for Python 3.4.\r\n- Setup: fix an improper dependencies versions.\r\n- Setup general update and cleanup.\r\n\r\n1.0.9 (2019-05-22)\r\n------------------\r\n- Drop support for Python 2.\r\n\r\n1.0.8 (2019-05-21)\r\n------------------\r\n- Update required setuptools version.\r\n- Setup update and improvements.\r\n- This is the latest release that supports Python 2.\r\n\r\n1.0.7 (2018-11-08)\r\n------------------\r\n- Drop support for Python 2.6 and 3.0-3.3.\r\n- Update required setuptools version.\r\n\r\n1.0.6 (2018-05-08)\r\n------------------\r\n- Fix a bug in description.\r\n- Update required setuptools version.\r\n- Improve and simplify setup and packaging.\r\n\r\n1.0.5 (2018-02-26)\r\n------------------\r\n- Improve and simplify setup and packaging.\r\n\r\n1.0.4 (2018-01-28)\r\n------------------\r\n- Fix a bug and inconsistencies in tox.ini\r\n- Update of README.rst.\r\n\r\n1.0.1 (2018-01-24)\r\n------------------\r\n- Update required Sphinx version.\r\n- Update doc Sphinx configuration files.\r\n\r\n1.0.0 (2017-11-18)\r\n------------------\r\n- Setup improvements.\r\n- Other minor improvements.\r\n\r\n1.0.0b1 (2017-11-18)\r\n--------------------\r\n- Minor improvements.\r\n\r\n0.3.4 (2017-01-05)\r\n------------------\r\n- Minor setup improvements.\r\n\r\n0.3.3 (2016-09-25)\r\n------------------\r\n- Fix bug in setup.py\r\n\r\n0.3.1 (2016-09-25)\r\n------------------\r\n- More PEP8 compliant.\r\n\r\n0.2.2 (2016-09-24)\r\n------------------\r\n- Description suplement\r\n- Minor fixes.\r\n\r\n0.1.1 (2016-09-24)\r\n------------------\r\n- First useful release.\r\n\r\n0.0.2 (2016-09-23)\r\n------------------\r\n- Initial release.\r\n",
    "bugtrack_url": null,
    "license": "zlib/libpng License ; https://opensource.org/license/zlib",
    "summary": "Reverse enumerate.",
    "version": "1.2.2",
    "project_urls": {
        "Documentation": "https://renumerate.readthedocs.io/",
        "Download": "https://pypi.org/project/renumerate/",
        "Homepage": "https://pypi.org/project/renumerate/",
        "Issues": "https://github.com/karpierz/renumerate/issues",
        "Source": "https://github.com/karpierz/renumerate"
    },
    "split_keywords": [
        "renumerate",
        " enumerate"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62c5cd167def5286a21a4a40b253eaefb56ce29e629aec6c0e8f0a96bcf1bdd4",
                "md5": "9e12d033afcd30dad30079a94f33c696",
                "sha256": "924ba44a45921db7b6999a9489648d4491afce74e68320676c9e85f4de6252b9"
            },
            "downloads": -1,
            "filename": "renumerate-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e12d033afcd30dad30079a94f33c696",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.9.0",
            "size": 5614,
            "upload_time": "2024-11-05T15:51:10",
            "upload_time_iso_8601": "2024-11-05T15:51:10.422614Z",
            "url": "https://files.pythonhosted.org/packages/62/c5/cd167def5286a21a4a40b253eaefb56ce29e629aec6c0e8f0a96bcf1bdd4/renumerate-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6343e3ba26782bfc3b49fe58ad46a208548a59840086843c96a3e427ddc86e05",
                "md5": "0366d26b723769996823b24335cb31ea",
                "sha256": "ac0fa491d02d6116b3376c5e86f93a5e7d8423fb42a7c0ba64299dd22c1a00c1"
            },
            "downloads": -1,
            "filename": "renumerate-1.2.2.zip",
            "has_sig": false,
            "md5_digest": "0366d26b723769996823b24335cb31ea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.9.0",
            "size": 19778,
            "upload_time": "2024-11-05T15:51:12",
            "upload_time_iso_8601": "2024-11-05T15:51:12.799584Z",
            "url": "https://files.pythonhosted.org/packages/63/43/e3ba26782bfc3b49fe58ad46a208548a59840086843c96a3e427ddc86e05/renumerate-1.2.2.zip",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 15:51:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "karpierz",
    "github_project": "renumerate",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "renumerate"
}
        
Elapsed time: 2.96391s