I use this
def cleaned( aFile ): for line in aFile: yield line.strip()
Then I can do such things.
lines = list( cleaned( open("file","r") ) )
Or, I can extend the cleaning with additional functions, for example, discard empty lines or skip comment lines or something else.
S.Lott Feb 13 '09 at 11:07 2009-02-13 11:07
source share