diff options
author | Yury Selivanov <yury@magic.io> | 2018-11-20 14:27:07 -0500 |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2018-11-20 14:27:33 -0500 |
commit | a617e2f24c994a7c57e4ed19dea6f95a95f0639a (patch) | |
tree | 0db3281c80aa9b579f80dbac77d2f4a86e957a90 | |
parent | 339d62fadafd0ab35a6394c2ad210b092704ce98 (diff) | |
download | immutables-a617e2f24c994a7c57e4ed19dea6f95a95f0639a.tar.gz immutables-a617e2f24c994a7c57e4ed19dea6f95a95f0639a.zip |
Fix README markup
-rw-r--r-- | README.rst | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -44,7 +44,9 @@ API are hashable, comparable, and pickleable. The ``Map`` object implements the ``collections.abc.Mapping`` ABC -so working with it is very similar to working with Python dicts. +so working with it is very similar to working with Python dicts: + +.. code-block:: python import immutables @@ -60,7 +62,9 @@ so working with it is very similar to working with Python dicts. # will print 'False' Since Maps are immutable, there is a special API for mutations that -allow apply changes to the Map object and create new (derived) Maps:: +allow apply changes to the Map object and create new (derived) Maps: + +.. code-block:: python map2 = map.set('a', 10) print(map, map2) @@ -75,7 +79,9 @@ allow apply changes to the Map object and create new (derived) Maps:: # <immutables.Map({'a': 10, 'b': 2})> # <immutables.Map({'a': 10})> -Maps also implement APIs for bulk updates: ``MapMutation`` objects:: +Maps also implement APIs for bulk updates: ``MapMutation`` objects: + +.. code-block:: python map_mutation = map.mutate() map_mutation['a'] = 100 @@ -90,7 +96,9 @@ Maps also implement APIs for bulk updates: ``MapMutation`` objects:: # <immutables.Map({'a': 100, 'y': 'y'})> ``MapMutation`` objects are context managers. Here's the above example -rewritten in a more idiomatic way:: +rewritten in a more idiomatic way: + +.. code-block:: python with map.mutate() as mm: mm['a'] = 100 |