zeroth
Efficiently get the index-0 element of an iterable.
This is a micro-package, containing the single function zeroth.
zeroth
is syntactic sugar for next(iter(obj)), with a nice docstring.
Installation
pip install zeroth
Documentation
from zeroth import zeroth
print(zeroth([0, 1, 2]))
# 0
print(zeroth((3, 2, 1)))
# 3
print(zeroth({"a": 1, "b": 2, "c": 3}))
# 'a'
print(zeroth(range(3)))
# 0
print(zeroth(range(1, 3)))
# 1
print(zeroth(map(str, range(3))))
# '0'
import numpy as np
print(zeroth(np.array([1, 2, 3])))
# 1
class ReverseIterable:
def __init__(self, data):
self.data = data
def __iter__(self):
return iter(reversed(self.data))
print(zeroth(ReverseIterable([1, 2, 3])))
# 3
Q&A
Why isn't this called first since it gets the element with ordinality of 1?
Because that package name is already taken on PyPI. Here zeroth refers to the index.
Metadata
Release files for zeroth 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zeroth-1.2.0.tar.gz | 115.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zeroth-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 119.8 kB
Release files / zeroth-1.2.0.tar.gz
| Download URL | zeroth-1.2.0.tar.gz |
|---|---|
| Size | 115.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d484a5f70800ab44189b5252401d18e9ce537c917081ee4e87dd86871d6b77f
|
|
BLAKE2b-256 checksum How to use checksums |
ded3e1cb496be02859e42763dd351e834f537a214e8deaebf0af247bbc2809f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 12, 2026.
Transparency logRelease files / zeroth-1.2.0-py3-none-any.whl
| Download URL | zeroth-1.2.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5eb008cd02eb6e44a2387b5d5421d39a86a8abfc5eae8d1ca8d09b97f572a075
|
|
BLAKE2b-256 checksum How to use checksums |
79663400e437c761dcfdc355d24620ae57d71fb29be0c339380864260069068e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 12, 2026.
Transparency log