News for hackers. Stuff that matters.
Re:A practical usage of ChainMap in Python by dangom on Monday September 24, 2018 @12:40PM (#18059123)
I see the example use case is exactly the same as the one given in the python documentation [1]. Any other practical use cases?

[1] https://docs.python.org/3.7/library/collections.html#collect...

Re:A practical usage of ChainMap in Python by thedirt0115 on Monday September 24, 2018 @04:27PM (#18061108)
It's nice for anything with nested scopes -- Example that came to mind since a link to Crafting Interpreters was also on the front page: Variable lookup for for an interpreter. If each scope gets its own set of bindings, you can make a ChainMap from most specific to least specific and look up values from that instead of manually traversing scopes.
Re:A practical usage of ChainMap in Python by mjw1007 on Monday September 24, 2018 @01:39PM (#18059650)
If you're implementing some kind of style sheet system, you often want to support a tower of overrides (say, theme → document → chapter → explicitly-marked-section).