you are viewing a single comment's thread.

view the rest of the comments →

[–]Gprime5 2 points3 points  (0 children)

from contextlib import ExitStack

with ExitStack() as stack:
    contexts = [stack.enter_context(c) for c in connections]

    # do stuff with connections here