Skip to main content

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

Project description

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

itermark-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file itermark-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: itermark-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for itermark-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd02f14613462fd7eef52eaff3bd3e018e1b8013cfe9d7269cfb12bdaafe112c
MD5 f5b40bd1502911bc324ee04fb2ba542b
BLAKE2b-256 1c007d91059bfd1d3f90a9eeece126b3823c096b6e5c2ae1432ca4fcd2977de8

See more details on using hashes here.

Supported by

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