Create a “with” block on several context managers? [duplicate]
This question already has answers here: Multiple variables in a ‘with’ statement? (8 answers) Closed 3 years ago. Suppose you have three objects you acquire via context manager, for instance A lock, a db connection and an ip socket. You can acquire them by: with lock: with db_con: with socket: #do stuff But is there … Read more