With more than one item, the context managers are processed as if multiplewith
statements were nested:with A() as a, B() as b: SUITE
is semantically equivalent to:
with A() as a: with B() as b: SUITE
You can also write multi-item context managers in multiple lines if the items are surrounded by parentheses. For example:
with ( A() as a, B() as b, ): SUITE
:O #Python
dieter_wilhelm likes this.
Tech Cyborg reshared this.
Neil E. Hodges
in reply to Neil E. Hodges • •try
with resources. :3Leafuw
in reply to Neil E. Hodges • • •Neil E. Hodges likes this.