Skip to main content

Stack-based datastructures: StackedDict.

Project description

wardrobe is a Python project about datastructures to manage contexts. It currently provides one class: StackedDict.

StackedDict is a dictionary-like object with additional methods to save the current state (commit) and restore it (reset).

Example:

>>> from wardrobe import StackedDict
>>> clark = StackedDict(top='blue bodysuit', bottom='red underpants',
...                     sex_appeal=True)
>>> clark['bottom']
'red underpants'
>>> clark['friend'] = 'Lois'
>>> dict(clark) == {'top': 'blue bodysuit',
...                 'bottom': 'red underpants',
...                 'friend': 'Lois',
...                 'sex_appeal': True}
True
>>> clark.commit()  # doctest: +ELLIPSIS
<wardrobe.stackeddict.StackedDict object at 0x...>
>>> clark.update({'top': 'shirt', 'bottom': 'jeans', 'head': 'glasses'})
>>> del clark['sex_appeal']
>>> dict(clark) == {'top': 'shirt',
...                 'bottom': 'jeans',
...                 'head': 'glasses',
...                 'friend': 'Lois'}
True
>>> clark.reset()  # doctest: +ELLIPSIS
<wardrobe.stackeddict.StackedDict object at 0x...>
>>> dict(clark) == {'top': 'blue bodysuit',
...                 'bottom': 'red underpants',
...                 'friend': 'Lois',
...                 'sex_appeal': True}
True

wardrobe.StackedDict is useful to create context objects, like Django’s django.template.context:Context objects.

Ressources

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

wardrobe-0.1.zip (11.6 kB view details)

Uploaded Source

File details

Details for the file wardrobe-0.1.zip.

File metadata

  • Download URL: wardrobe-0.1.zip
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wardrobe-0.1.zip
Algorithm Hash digest
SHA256 58dc8ea04287e6c5ef64e7ded7f145105b8830ca75081a2c9109f4c07b55f4ac
MD5 7c383c1c840862816eaa1a94e9803109
BLAKE2b-256 25f3214f411f8dc639ea8fbfd4ae2c9cc25f43fa43ef618ab34318c3699da1f5

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