Jack Diederich Python has two useful conventions for "I mean it, but only here" and you can say it with Context Managers and Decorators. Both give you the power to define a push/pop of a resource for a set period inside a namespace, be it a function or a level of indentation. This talk is a list of patterns that are implemented by one or the other (including some clever functions that are both).