I came across this syntax for reading the lines in a file.
with open(...) as f:
for line in f:
<do something with line>
Say I wanted the <do something with line>
line to append each line to a list. Is there any way to accomplish this, using the with
keyword, in a list comprehension? Or, is there at least some way of doing what I want in a single statement?