-
Notifications
You must be signed in to change notification settings - Fork 0
A stack-based dictionary-like datastructure for Python: StackedDict
License
benoitbryon/wardrobe
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
######## wardrobe ######## 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 ********** * online documentation: http://wardrobe.readthedocs.org * PyPI page: http://pypi.python.org/pypi/wardrobe * code repository: https://github.com/benoitbryon/wardrobe * bugtracker: https://github.com/benoitbryon/wardrobe/issues
About
A stack-based dictionary-like datastructure for Python: StackedDict
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published