From 837bdbb5f4baf586751f55156d32fae32bcab744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Zadro=C5=BCny?= Date: Sat, 6 May 2017 12:13:46 +0200 Subject: [PATCH] docs update --- README.rst | 2 ++ docs/usage.rst | 30 +++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index f6e5df5..6a373fb 100644 --- a/README.rst +++ b/README.rst @@ -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. diff --git a/docs/usage.rst b/docs/usage.rst index c18f652..7195880 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -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. @@ -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, @@ -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.