#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2008 Doug Hellmann All rights reserved. # """ $Id$ """ #end_pymotw_header import contextlib @contextlib.contextmanager def make_context(name): print 'entering:', name yield name print 'exiting :', name with make_context('A') as A, make_context('B') as B, make_context('C') as C: print 'inside with statement:', A, B, C