FlatDictPython module for interacting with nested dicts as a single level dict with delimited keys | |
Download |
FlatDict Ranking & Summary
Advertisement
- License:
- BSD License
- Price:
- FREE
- Publisher Name:
- Gavin M. Roy
- Publisher web site:
- http://area51.myyearbook.com/trac.cgi/wiki/Staplr
FlatDict Tags
FlatDict Description
FlatDict is a dict object that allows for single level, delimited key/value pair mapping of nested dictionaries. You can interact with FlatDict like a normal dictionary and access child dicts as you normally would or with the composited key.For example:foo = {'foo': {'bar': 'baz', 'qux': 'corge'}}is represented as:{'foo:bar': 'baz', 'foo'qux': 'corge'}And can still be accessed as:fooandfooAPIFlatDict has the same methods as dict in Python 2.6.Installationeasy_install flatdictExample Useimport flatdictvalues = {'foo': {'bar': {'baz': 0, 'qux': 1, 'corge': 2}, 'grault': {'baz': 3, 'qux': 4, 'corge': 5}}, 'garply': {'foo': 0, 'bar': 1, 'baz': 2, 'qux': {'corge': 3}}}flat = flatdict.FlatDict(values)print flatflat = 10del flatfor key in flat: print keyfor values in flat.itervalues(): print keyProduct's homepage
FlatDict Related Software