On 30/07/18 20:15, Rudy Matela wrote:
Hello,

Do you think it would be nice to allow with statements inside genexps or
list comprehensions?  The functions __enter__ and __exit__ would be
automatically called as iterables are traversed.  I am thinking of
drafting a PEP about this.  Examples:

I was worried until I twigged that you meant adding a clause rather than a statement per se. How does this interact with the other clauses in a comprehension? I'm thinking of monstrosities like:

g = (f.read() for fn in filenames if fn.endswith(".txt") with open(fn) as f for filenames in get_directory_listing(dir) if .....)

--
Rhodri James *-* Kynesim Ltd
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to