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
|
||||
contexts::
|
||||
|
||||
c = ChainMap() Create root context
|
||||
d = c.new_child() Create nested child context
|
||||
e = c.new_child() Child of c, independent from d
|
||||
e.maps[0] Current context dictionary -- like Python's locals()
|
||||
e.maps[-1] Root context -- like Python's globals()
|
||||
e.parents Enclosing context chain -- like Python's nonlocals
|
||||
c = ChainMap() # Create root context
|
||||
d = c.new_child() # Create nested child context
|
||||
e = c.new_child() # Child of c, independent from d
|
||||
e.maps[0] # Current context dictionary -- like Python's locals()
|
||||
e.maps[-1] # Root context -- like Python's globals()
|
||||
e.parents # Enclosing context chain -- like Python's nonlocals
|
||||
|
||||
d['x'] Get first key in the chain of contexts
|
||||
d['x'] = 1 Set value in current context
|
||||
del['x'] Delete from current context
|
||||
list(d) All nested values
|
||||
k in d Check all nested values
|
||||
len(d) Number of nested values
|
||||
d.items() All nested items
|
||||
dict(d) Flatten into a regular dictionary
|
||||
d['x'] # Get first key in the chain of contexts
|
||||
d['x'] = 1 # Set value in current context
|
||||
del['x'] # Delete from current context
|
||||
list(d) # All nested values
|
||||
k in d # Check all nested values
|
||||
len(d) # Number of nested values
|
||||
d.items() # All nested items
|
||||
dict(d) # Flatten into a regular dictionary
|
||||
|
||||
.. 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
|
||||
<http://code.activestate.com/recipes/305268/>`_.
|
||||
|
||||
|
||||
:class:`Counter` objects
|
||||
------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue