Fix indentation.
This commit is contained in:
parent
50dbb3f2cf
commit
4dcf474337
|
@ -112,21 +112,21 @@ The class can be used to simulate nested scopes and is useful in templating.
|
||||||
Example patterns for using the :class:`ChainMap` class to simulate nested
|
Example patterns for using the :class:`ChainMap` class to simulate nested
|
||||||
contexts::
|
contexts::
|
||||||
|
|
||||||
c = ChainMap() Create root context
|
c = ChainMap() # Create root context
|
||||||
d = c.new_child() Create nested child context
|
d = c.new_child() # Create nested child context
|
||||||
e = c.new_child() Child of c, independent from d
|
e = c.new_child() # Child of c, independent from d
|
||||||
e.maps[0] Current context dictionary -- like Python's locals()
|
e.maps[0] # Current context dictionary -- like Python's locals()
|
||||||
e.maps[-1] Root context -- like Python's globals()
|
e.maps[-1] # Root context -- like Python's globals()
|
||||||
e.parents Enclosing context chain -- like Python's nonlocals
|
e.parents # Enclosing context chain -- like Python's nonlocals
|
||||||
|
|
||||||
d['x'] Get first key in the chain of contexts
|
d['x'] # Get first key in the chain of contexts
|
||||||
d['x'] = 1 Set value in current context
|
d['x'] = 1 # Set value in current context
|
||||||
del['x'] Delete from current context
|
del['x'] # Delete from current context
|
||||||
list(d) All nested values
|
list(d) # All nested values
|
||||||
k in d Check all nested values
|
k in d # Check all nested values
|
||||||
len(d) Number of nested values
|
len(d) # Number of nested values
|
||||||
d.items() All nested items
|
d.items() # All nested items
|
||||||
dict(d) Flatten into a regular dictionary
|
dict(d) # Flatten into a regular dictionary
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
@ -151,6 +151,7 @@ The class can be used to simulate nested scopes and is useful in templating.
|
||||||
* A `greatly simplified read-only version of Chainmap
|
* A `greatly simplified read-only version of Chainmap
|
||||||
<http://code.activestate.com/recipes/305268/>`_.
|
<http://code.activestate.com/recipes/305268/>`_.
|
||||||
|
|
||||||
|
|
||||||
:class:`Counter` objects
|
:class:`Counter` objects
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue