# A "fast-forward and rewind" custom iterator for flexible traversal through iterables
## Tested against Windows / Python 3.11 / Anaconda
## pip install loophopper
```python
from loophopper import FFIter
# Create an FFIter object for a range iterable
l = FFIter(range(40), ignore_exceptions=True, exception_replacement=None)
for no in l:
if no % 10 == 0:
print(f"number: {no}, 2 forward: {l.forward(2)}")
if no % 7 == 0:
print(f"number: {no}, 1 back: {l.back(1)}")
# Create an FFIter object for a dictionary iterable
l = FFIter(
{k: k * 2 for k in range(40)}, ignore_exceptions=True, exception_replacement=None
)
for no in l:
if no[0] % 10 == 0:
print(f"number: {no}, 2 forward: {l.forward(2)}")
if no[1] % 7 == 0:
print(f"number: {no}, 1 back: {l.back(1)}")
l = FFIter(
{k: k * 2 for k in range(40)}, ignore_exceptions=True, exception_replacement=None
)
for no in l:
if l.active_index%5==0:
print(f'{l.active_index}: {no}')
# number: 0, 2 forward: 2
# number: 0, 1 back: None
# number: 7, 1 back: 6
# number: 10, 2 forward: 12
# number: 14, 1 back: 13
# number: 20, 2 forward: 22
# number: 21, 1 back: 20
# number: 28, 1 back: 27
# number: 30, 2 forward: 32
# number: 35, 1 back: 34
# number: (0, 0), 2 forward: (2, 4)
# number: (0, 0), 1 back: None
# number: (7, 14), 1 back: (6, 12)
# number: (10, 20), 2 forward: (12, 24)
# number: (14, 28), 1 back: (13, 26)
# number: (20, 40), 2 forward: (22, 44)
# number: (21, 42), 1 back: (20, 40)
# number: (28, 56), 1 back: (27, 54)
# number: (30, 60), 2 forward: (32, 64)
# number: (35, 70), 1 back: (34, 68)
# 0: (0, 0)
# 5: (5, 10)
# 10: (10, 20)
# 15: (15, 30)
# 20: (20, 40)
# 25: (25, 50)
# 30: (30, 60)
# 35: (35, 70)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/loophopper",
"name": "loophopper",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "fast-forward,rewind,loop",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/30/2d/fc6d06511239a52ccd1dbb52ebf625bca1f58c344b61dba4f830f9e83a0a/loophopper-0.10.tar.gz",
"platform": null,
"description": "\r\n# A \"fast-forward and rewind\" custom iterator for flexible traversal through iterables \r\n\r\n## Tested against Windows / Python 3.11 / Anaconda\r\n\r\n## pip install loophopper\r\n\r\n```python\r\nfrom loophopper import FFIter\r\n# Create an FFIter object for a range iterable\r\nl = FFIter(range(40), ignore_exceptions=True, exception_replacement=None)\r\nfor no in l:\r\n\tif no % 10 == 0:\r\n\t\tprint(f\"number: {no}, 2 forward: {l.forward(2)}\")\r\n\tif no % 7 == 0:\r\n\t\tprint(f\"number: {no}, 1 back: {l.back(1)}\")\r\n\r\n# Create an FFIter object for a dictionary iterable\r\nl = FFIter(\r\n\t{k: k * 2 for k in range(40)}, ignore_exceptions=True, exception_replacement=None\r\n)\r\nfor no in l:\r\n\tif no[0] % 10 == 0:\r\n\t\tprint(f\"number: {no}, 2 forward: {l.forward(2)}\")\r\n\tif no[1] % 7 == 0:\r\n\t\tprint(f\"number: {no}, 1 back: {l.back(1)}\")\r\n\r\nl = FFIter(\r\n\t{k: k * 2 for k in range(40)}, ignore_exceptions=True, exception_replacement=None\r\n)\r\nfor no in l:\r\n\tif l.active_index%5==0:\r\n\t\tprint(f'{l.active_index}: {no}')\r\n\r\n# number: 0, 2 forward: 2\r\n# number: 0, 1 back: None\r\n# number: 7, 1 back: 6\r\n# number: 10, 2 forward: 12\r\n# number: 14, 1 back: 13\r\n# number: 20, 2 forward: 22\r\n# number: 21, 1 back: 20\r\n# number: 28, 1 back: 27\r\n# number: 30, 2 forward: 32\r\n# number: 35, 1 back: 34\r\n# number: (0, 0), 2 forward: (2, 4)\r\n# number: (0, 0), 1 back: None\r\n# number: (7, 14), 1 back: (6, 12)\r\n# number: (10, 20), 2 forward: (12, 24)\r\n# number: (14, 28), 1 back: (13, 26)\r\n# number: (20, 40), 2 forward: (22, 44)\r\n# number: (21, 42), 1 back: (20, 40)\r\n# number: (28, 56), 1 back: (27, 54)\r\n# number: (30, 60), 2 forward: (32, 64)\r\n# number: (35, 70), 1 back: (34, 68)\r\n# 0: (0, 0)\r\n# 5: (5, 10)\r\n# 10: (10, 20)\r\n# 15: (15, 30)\r\n# 20: (20, 40)\r\n# 25: (25, 50)\r\n# 30: (30, 60)\r\n# 35: (35, 70)\r\n\r\n```\r\n\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A \"fast-forward and rewind\" custom iterator for flexible traversal through iterables",
"version": "0.10",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/loophopper"
},
"split_keywords": [
"fast-forward",
"rewind",
"loop"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1e88cdf7c91316337ddee80cd0e94073722005cd4af41dbafff5179ab77b12c0",
"md5": "c0a2d5f0df900326c4b8469b3fe94cb7",
"sha256": "6417654607930912d67a4685e6faffdc3ea4a543bfd2e69ebd963b455816967e"
},
"downloads": -1,
"filename": "loophopper-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c0a2d5f0df900326c4b8469b3fe94cb7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5449,
"upload_time": "2023-10-15T02:56:10",
"upload_time_iso_8601": "2023-10-15T02:56:10.267200Z",
"url": "https://files.pythonhosted.org/packages/1e/88/cdf7c91316337ddee80cd0e94073722005cd4af41dbafff5179ab77b12c0/loophopper-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "302dfc6d06511239a52ccd1dbb52ebf625bca1f58c344b61dba4f830f9e83a0a",
"md5": "a92f753362a7b7c793d4353f7e0a0c9f",
"sha256": "dc2fa0d20b987e23377ab9a480784fc63efef9e4371c867906e8d00cafd97a05"
},
"downloads": -1,
"filename": "loophopper-0.10.tar.gz",
"has_sig": false,
"md5_digest": "a92f753362a7b7c793d4353f7e0a0c9f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4310,
"upload_time": "2023-10-15T02:56:11",
"upload_time_iso_8601": "2023-10-15T02:56:11.633723Z",
"url": "https://files.pythonhosted.org/packages/30/2d/fc6d06511239a52ccd1dbb52ebf625bca1f58c344b61dba4f830f9e83a0a/loophopper-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-15 02:56:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "loophopper",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "loophopper"
}