diff --git a/boltons/cacheutils.py b/boltons/cacheutils.py index 289631b..cef0b4e 100644 --- a/boltons/cacheutils.py +++ b/boltons/cacheutils.py @@ -73,7 +73,8 @@ class LRU(dict): >>> cap_cache = LRU(max_size=2) >>> cap_cache['a'], cap_cache['b'] = 'A', 'B' - >>> dict(cap_cache) + >>> from pprint import pprint as pp + >>> pp(dict(cap_cache)) {'a': 'A', 'b': 'B'} >>> [cap_cache['b'] for i in range(3)][0] 'B' @@ -255,7 +256,8 @@ class LRI(dict): >>> cap_cache = LRI(max_size=2) >>> cap_cache['a'], cap_cache['b'] = 'A', 'B' - >>> cap_cache + >>> from pprint import pprint as pp + >>> pp(cap_cache) {'a': 'A', 'b': 'B'} >>> [cap_cache['b'] for i in range(3)][0] 'B' diff --git a/boltons/dictutils.py b/boltons/dictutils.py index 0e18c81..1b56bd9 100644 --- a/boltons/dictutils.py +++ b/boltons/dictutils.py @@ -101,16 +101,17 @@ class OrderedMultiDict(dict): Note that calling :func:`dict` on an OMD results in a dict of keys to *lists* of values: + >>> from pprint import pprint as pp # ensuring proper key ordering >>> omd = OrderedMultiDict([('a', 1), ('b', 2), ('a', 3)]) - >>> dict(omd) + >>> pp(dict(omd)) {'a': [1, 3], 'b': [2]} Note that modifying those lists will modify the OMD. If you want a safe-to-modify or flat dictionary, use :meth:`OrderedMultiDict.todict()`. - >>> omd.todict() + >>> pp(omd.todict()) {'a': 3, 'b': 2} - >>> omd.todict(multi=True) + >>> pp(omd.todict(multi=True)) {'a': [1, 3], 'b': [2]} With ``multi=False``, items appear with the keys in to original