Hi All The original poster wanted, inside 'with' context management, to open several files. Context management is, roughly speaking, deferred execution wrapped in a try ... except .... statement.
The lambda construction also provides for deferred execution. Perhaps something like >>> with helper(lambda: open('a'), open('b'), open('c')) as a, b c: >>> pass would do what the original poster wanted, for a suitable value of helper. It certainly gives the parentheses the OP wanted, without introducing new syntax. However, map also provides for deferred execution. It returns an iterable (not a list). >>> x = map(open, ['a', 'b', 'c']) >>> x <map object at 0x7f8cb5653b70> >>> next(x) FileNotFoundError: [Errno 2] No such file or directory: 'a' So the OP could even write: >>> with helper(map(open, ['a', 'b', 'c'])) as a, b, c: >>> pass for a (different) suitable value of helper. I hope this helps. -- Jonathan URL: jfine2358.github.io
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VTMXRIEUXJQNIS6BRKIQTG2FEHO2AEB7/ Code of Conduct: http://python.org/psf/codeofconduct/