Python multi-line with statement
问题 What is a clean way to create a multi-line with in python? I want to open up several files inside a single with , but it's far enough to the right that I want it on multiple lines. Like this: class Dummy: def __enter__(self): pass def __exit__(self, type, value, traceback): pass with Dummy() as a, Dummy() as b, Dummy() as c: pass Unfortunately, that is a SyntaxError . So I tried this: with (Dummy() as a, Dummy() as b, Dummy() as c): pass Also a syntax error. However, this worked: with Dummy()