Skip to main content

A "fast-forward and rewind" custom iterator for flexible traversal through iterables

Project description

A "fast-forward and rewind" custom iterator for flexible traversal through iterables

Tested against Windows / Python 3.11 / Anaconda

pip install loophopper

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loophopper-0.10.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

loophopper-0.10-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file loophopper-0.10.tar.gz.

File metadata

  • Download URL: loophopper-0.10.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for loophopper-0.10.tar.gz
Algorithm Hash digest
SHA256 dc2fa0d20b987e23377ab9a480784fc63efef9e4371c867906e8d00cafd97a05
MD5 a92f753362a7b7c793d4353f7e0a0c9f
BLAKE2b-256 302dfc6d06511239a52ccd1dbb52ebf625bca1f58c344b61dba4f830f9e83a0a

See more details on using hashes here.

File details

Details for the file loophopper-0.10-py3-none-any.whl.

File metadata

  • Download URL: loophopper-0.10-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for loophopper-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 6417654607930912d67a4685e6faffdc3ea4a543bfd2e69ebd963b455816967e
MD5 c0a2d5f0df900326c4b8469b3fe94cb7
BLAKE2b-256 1e88cdf7c91316337ddee80cd0e94073722005cd4af41dbafff5179ab77b12c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page