diff --git a/README.rst b/README.rst index dc76c4c..36b8fb2 100644 --- a/README.rst +++ b/README.rst @@ -107,17 +107,17 @@ The `copy` method (which returns a shallow copy of the mapping) returns a Recursive attribute access results in a shallow copy, so recursive assignment will fail (as you will be writing to a copy of that dictionary):: - > attr = AttrDict('foo': {}) + > attr = AttrDict({'foo': {}}) > attr.foo.bar = 'baz' > attr.foo - {} +   AttrDict({}) Assignment as keys will still work:: - > attr = AttrDict('foo': {}) + > attr = AttrDict({'foo': {}}) > attr['foo']['bar'] = 'baz' > attr.foo - {'bar': 'baz'} + AttrDict({'bar': 'baz'}) If either of these caveats are deal-breakers, or you don't need your object to be a `dict`, consider using `AttrMap` instead. @@ -156,7 +156,7 @@ NOTE: AttrDict's add is not commutative, ``a + b != b + a``:: > a = {'foo': 'bar', 'alpha': {'beta': 'b', 'a': 0}} > b = {'lorem': 'ipsum', 'alpha': {'bravo': 'b', 'a': 1}} > b + AttrDict(a) - {'foo': 'bar', 'lorem': 'ipsum', 'alpha': {'beta': 'a', 'bravo': 'b', 'a': }} + {'foo': 'bar', 'lorem': 'ipsum', 'alpha': {'beta': 'a', 'bravo': 'b', 'a': 0}} Sequences --------- @@ -173,7 +173,7 @@ This will not occur if you access the AttrDict as a dictionary:: > adict = AttrDict({'list': [{'value': 1}, {'value': 2}]}) > for element in adict['list']: - > isinstance(element, AttrDict) + > print(isinstance(element, AttrDict)) False False @@ -182,9 +182,9 @@ the constructor:: > adict = AttrDict({'list': [{'value': 1}, {'value': 2}]}, recursive=False) > for element in adict.list: - > isinstance(element, AttrDict) - False - False + > print(isinstance(element, AttrDict)) + True + True When merging an AttrDict with another mapping, this behavior will be disabled if at least one of the merged items is an AttrDict that has set ``recursive``