This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Marcos Soutullo
Recipients Marcos Soutullo, docs@python
Date 2017-07-29.12:24:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501331057.19.0.539549352975.issue31075@psf.upfronthosting.co.za>
In-reply-to
Content
Hello,

I have been taking a look into your ChainMap collections documentation (https://docs.python.org/3.6/library/collections.html?highlight=collections#collections.ChainMap), specifically the third code example on "8.3.1.1. ChainMap Examples and Recipes"
that clearly describe and illustrate a use case for the ChainMap class. However, I found a very small code issue in regards to how the sample code (line 7) is presented to the reader. Please refer to the code compilation below:

Line 7 >>> d['x']                # Get first key in the chain of contexts
raise KeyError(key)
KeyError: 'x'
Line 8 >>> d['x'] d['x'] = 1            # Set value in current context

The key named 'x' had not been initialised yet and of course, the compiler is complaining. It should be the other way around.

Line 8 >>> d['x'] = 1   # Set value in current context
Line 7 >>> d['x']       # Get first key in the chain of contexts


Many thanks for the great work you do with Python,

Marcos S.
History
Date User Action Args
2017-07-29 12:24:17Marcos Soutullosetrecipients: + Marcos Soutullo, docs@python
2017-07-29 12:24:17Marcos Soutullosetmessageid: <1501331057.19.0.539549352975.issue31075@psf.upfronthosting.co.za>
2017-07-29 12:24:17Marcos Soutullolinkissue31075 messages
2017-07-29 12:24:16Marcos Soutullocreate