Metadata-Version: 2.4
Name: renumerate
Version: 2.3.0
Summary: Reverse enumerate.
Author-email: Adam Karpierz <adam@karpierz.net>
Maintainer-email: Adam Karpierz <adam@karpierz.net>
License-Expression: Zlib
Project-URL: Homepage, https://pypi.org/project/renumerate/
Project-URL: Documentation, https://karpierz.github.io/renumerate/
Project-URL: History, https://karpierz.github.io/renumerate/CHANGES.html
Project-URL: Download, https://pypi.org/project/renumerate/
Project-URL: Repository, https://github.com/karpierz/renumerate
Project-URL: Tracker, https://github.com/karpierz/renumerate/issues
Project-URL: Sponsoring, https://www.paypal.com/donate/?hosted_button_id=FX8L7CJUGLW7S
Keywords: renumerate,enumerate
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: Polish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: <4.0.0,>=3.10.0
Description-Content-Type: text/x-rst; charset=UTF-8
License-File: LICENSE
Requires-Dist: typing-extensions>=4.15.0
Requires-Dist: pkg-about>=2.3.0
Dynamic: license-file

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.10 or higher

  * https://www.python.org/

+ pip

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

To install run:

  .. parsed-literal::

    python -m pip install --upgrade |package|

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

Prerequisites:

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

    python -m pip install --upgrade nox

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>

Sponsoring
==========

| If you would like to sponsor the development of this project, your contribution
  is greatly appreciated.
| As I am now retired, any support helps me dedicate more time to maintaining and
  improving this work.

`Donate`_

.. |package| replace:: renumerate
.. |package_bold| replace:: **renumerate**
.. |copyright| replace:: Copyright (c) 2016-2026 Adam Karpierz
.. |respository| replace:: https://github.com/karpierz/renumerate
.. _Development page: https://github.com/karpierz/renumerate
.. _PyPI record: https://pypi.org/project/renumerate/
.. _Documentation: https://karpierz.github.io/renumerate/
.. _Donate: https://www.paypal.com/donate/?hosted_button_id=FX8L7CJUGLW7S
.. _enumerate: https://docs.python.org/library/functions.html#enumerate
