Skip to main content

Itermark

Extension for iterable data types; adds boundwise bookmark iteration, enabling active item tracking/setting (type allowing)

Ideal for 'paging' through iterables

Installation

pip install itermark

Using Itermark

>>> from itermark import Itermark
>>> iterlist = Itermark(['zero', 'one', 'two', 'three'])
>>> iterlist.active
'zero'
>>> iterlist.mark += 2
>>> iterlist.active
'two'
>>> iterlist.mark = 5   # Would put mark outside active index
>>> iterlist.active
'three'                 # Defaults to highest upper bound
>>> iterlist.active = 'new three'
>>> iterlist.active
'new three'

The Itermark extension adds two properties (three for dicts), and two functions to it's objects. Note that all itermark attributes are disabled if underlying iterable is empty

mark

Acts as a bookmark index, and can be assigned a value directly (iterlist.mark = 2) or by operator assignment (iterlist.mark += 1, iterlist.mark -= 1)

active

Retrieves nth item from iterable where self.mark = n. Dictionary Itermarks return nth value

activekey

Dict specific, retrieves nth key from dictonary type where self.mark = n. Note that itermark was made post 3.6's insertion ordered dicts. While itermark properties still work pre 3.6, collections.OrderedDict is recommended and supported

markend()

Set mark to end value. Mark will never go above upper bound, but without calling len() user may not know what that upper bound is. Use .markend() to reliably set mark to upper bound

Supported types

list

Original implementation, full mark and active usage

`tuple

No active assignment `

dict

Uses iterator gen for mark and active properties. active calls and sets values, activekey calls immutable keys

OrderedDict

Same features as a regular dict, but for pre 3.6 implementation

string

Sure, strings are just a list of characters

set

Look, I don't know who'd want bookmark iteration through a set but here ya go

Release files for itermark 0.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for itermark 0.1.0
File Interpreter ABI Platform
itermark-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / itermark-0.1.0-py3-none-any.whl

Download URL itermark-0.1.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd02f14613462fd7eef52eaff3bd3e018e1b8013cfe9d7269cfb12bdaafe112c
BLAKE2b-256 checksum
How to use checksums
1c007d91059bfd1d3f90a9eeece126b3823c096b6e5c2ae1432ca4fcd2977de8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

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