with open("foo.txt") as foo_file:
data = foo_file.read()
from contextlib import nested
with nested(A(), B(), C()) as(X, Y, Z):
do_something()
with open('data') as input_file, open('result', 'w') as output_file:
for line in input_file:
output_file.write(parse(line))
lock = threading.Lock()
with lock: #Critical section of code