Skip to content

Instantly share code, notes, and snippets.

@treyhunner
Created February 20, 2016 01:08
Show Gist options
  • Save treyhunner/5260810b4cced03359d9 to your computer and use it in GitHub Desktop.
Save treyhunner/5260810b4cced03359d9 to your computer and use it in GitHub Desktop.
Removing items from a ChainMap
>>> from collections import ChainMap
>>> user_context = {'name': "Trey", 'website': "http://treyhunner.com"}
>>> global_context = {'name': "Anonymous User", 'page_name': "Profile Page"}
>>> context = ChainMap({}, user_context, global_context)
>>> context['page_name'] = "About Page"
>>> context['page_name']
'About Page'
>>> del context['page_name']
>>> context['page_name']
'Profile Page'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment