John Salerno wrote: > Paul Rubin wrote: > >>John Salerno <[EMAIL PROTECTED]> writes: >> >>>Interesting. So I would say: >>> >>>[line.rstrip() for line in open('C:\\switches.txt')] > > > > How would I manually close a file that's been opened this way? Or is it > not possible in this case? Is it necessary?
It's not possible to perform an explicit close if, as in this case, you don't have an explicit reference to the file object. 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. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list