Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Update README.rst #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
---------
Expand All @@ -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

Expand All @@ -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``
Expand Down