Skip to main content

find-step supplements Python str.find() and bytes.find() methods with an extra step argument - just like slicing has s[start:end:step].

Usage

If step is None, 1, or omitted then behaviour is unchanged from str.find() or bytes.find().

>>> import find_step
>>> find_step.find('.a.a.a.a', 'a')  # Same as '.a.a.a.a'.find('a')
1

If step is 2 or higher then only indexes satisfying start + n * step are tried, where n >= 0.

>>> find_step.find('.a.a.a.a', 'a', None, None, 3)  # Tries index 0, then index 3
3
>>> find_step.find('hello', 'l', 1, None, 2)  # Tries index 1, then index 1 + 2 = 3
3
>>> find_step.find('abcde', 'c', 1, None, 2)  # Tries index 1, then 3, then 5
-1

If step is O then ValueError is raised, as in slice notation.

>>> find_step.find('abc', 'a', None, None, 0)
Traceback (most recent call last):
    ...
ValueError: slice step cannot be zero

Install

python3 -m pip install find-step`

or

uv pip install find-step

License

MIT

Metadata

Release files for find-step 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for find-step 0.0.2
File Size Uploaded
find_step-0.0.2.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for find-step 0.0.2
File Interpreter ABI Platform
find_step-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / find_step-0.0.2.tar.gz

Download URL find_step-0.0.2.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d8b0bbf2d94987b61b63eab22865c36f5b9db19aedb22d96ddc2c98be7e67f26
BLAKE2b-256 checksum
How to use checksums
5fc71995a74212e5f9e19486fcb9f0f247762dd3cbb12b589d059bdd245d400e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / find_step-0.0.2-py3-none-any.whl

Download URL find_step-0.0.2-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a8341f32199445964dbbdd7d90321ff40cdd0a878ba4637fcfa686f95bf8fbd
BLAKE2b-256 checksum
How to use checksums
f2f8677e6600411e8c8a004a30a25fbe3ed7064086ac03bc9afed16ea7e58b86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page