All the str.find() goodness, now with a step argument
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file find_step-0.0.2.tar.gz.
File metadata
- Download URL: find_step-0.0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8b0bbf2d94987b61b63eab22865c36f5b9db19aedb22d96ddc2c98be7e67f26
|
|
| MD5 |
8e7ea72b5737ac41637b986c82ef26df
|
|
| BLAKE2b-256 |
5fc71995a74212e5f9e19486fcb9f0f247762dd3cbb12b589d059bdd245d400e
|
File details
Details for the file find_step-0.0.2-py3-none-any.whl.
File metadata
- Download URL: find_step-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a8341f32199445964dbbdd7d90321ff40cdd0a878ba4637fcfa686f95bf8fbd
|
|
| MD5 |
c56d4815573fcf8fdbd406180f6b2aee
|
|
| BLAKE2b-256 |
f2f8677e6600411e8c8a004a30a25fbe3ed7064086ac03bc9afed16ea7e58b86
|