Skip to content

Commit

Permalink
docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelzny committed May 6, 2017
1 parent 64548af commit 837bdbb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Dotty dictionary with support_for['dot.notation.keys'].
Dotty dict-like object allow to access deeply nested keys using dot notation.
Create Dotty from dict or other dict-like object to use magic of Dotty.

Ultimate goal is to match all Python dictionary method to work with deeply nested **Dotty** keys.


* Free software: MIT license
* Documentation: https://dotty-dict.readthedocs.io.
Expand Down
30 changes: 25 additions & 5 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ To use **Dotty** in a project::
>>> dotty
{'first': {'second': {'deep': 'i am here!', 'deeper': {'better': {'faster': {'stronger': 'ohh!'}}}}}}

Methods
-------
Operations
----------

Ultimate goal is to match all Python dictionary method to work with deeply nested **Dotty** keys.
**len(d)**

Return the number of items in the **Dotty** dictionary *d*.

**d[** *'key.key.key'* **]**
++++++++++++++++++++++++++++

Return the item of d with dot notation key. Returns None if key is not in the map.

Expand All @@ -51,10 +52,22 @@ Return the item of d with dot notation key. Returns None if key is not in the ma
>>> dotty['foo.bar'] += ' & fizz'
>>> dotty
{'foo': {'bar': 'baz & fizz'}}
>>> dotty['foo.bar']
'baz & fizz'

**d[** *'key.key.key'* **] = value**

Set deeply nested *key.key.key* to value

::

>>> from dotty_dict import Dotty
>>> dotty = Dotty()
>>> dotty['foo.bar'] = 'baz'
>>> dotty
{'foo': {'bar': 'baz'}}

**.get(** *'key.key.key'* **[,** *default* **])**
+++++++++++++++++++++++++++++++++++++++++++++++++

If deeply nested key is in dictionary return it's value,
but if key doesn't exist or it's value is None then return optional default value,
Expand All @@ -72,3 +85,10 @@ default defaults to None.
>>> value
'foo'

**.clear()**

Removes all items from **Dotty** dict

**.copy()**

Return a shallow copy of the dictionary.

0 comments on commit 837bdbb

Please sign in to comment.