P
Paul Rubin
Steve Holden said:How would I manually close a file that's been opened this way? Or is[line.rstrip() for line in open('C:\\switches.txt')]
it not possible in this case? Is it necessary?
In CPython it's not strictly necessary to close the file, but other
implementations don't guarantee that a file will be closed after the
last reference is deleted.
So for fullest portability it's better explicitly close the file.
I wonder whether PEP 343 should be extended somehow. Hmm.
[line.rstrip() for line within open('C:\\switches.txt')] # ugh!!
Other ideas?