son – Tools for working with SON, an ordered mapping
Tools for creating and manipulating SON, the Serialized Ocument Notation.
Regular dictionaries can be used instead of SON objects, but not when the orderof keys is important. A SON object can be used just like a normal Pythondictionary.
A subclass of dict that maintains ordering of keys and provides afew extra niceties for dealing with SON. SON provides an APIsimilar to collections.OrderedDict from Python 2.7+.
clear
() → None. Remove all items from D.copy
() → a shallow copy of Dget
(k[, d]) → D[k] if k in D, else d. d defaults to None.haskey
(_k) → True if D has a key k, else Falseitems
() → list of D's (key, value) pairs, as 2-tuplesiteritems
() → an iterator over the (key, value) items of Diterkeys
() → an iterator over the keys of Ditervalues
() → an iterator over the values of Dkeys
() → list of D's keyspop
(k[, d]) → v, remove specified key and return the corresponding value.If key is not found, d is returned if given, otherwise KeyError is raised
popitem
() → (k, v), remove and return some (key, value) pair as a2-tuple; but raise KeyError if D is empty.
setdefault
(k[, d]) → D.get(k,d), also set D[k]=d if k not in Dto_dict
()- Convert a SON document to a normal Python dictionary instance.
This is trickier than just dict(…) because it needs to berecursive.