With more than one item, the context managers are processed as if multiplewithstatements were nested:with A() as a, B() as b: SUITEis semantically equivalent to:
with A() as a: with B() as b: SUITEYou 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
Tech Cyborg reshared this.
Neil E. Hodges
in reply to Neil E. Hodges • •trywith resources. :3Leafuw
in reply to Neil E. Hodges • • •Neil E. Hodges likes this.