How to get rid the new line
Matt Gerrans
mgerrans at mindspring.com
Thu Jun 27 12:17:00 EDT 2002
> ## remove all the leading and tail white space
> line = string.strip(aline)
> if line:
> # this is an emptyLine
I like this one best; a regular expression seems like overkill and assuming
that the line is just the one '\n' character (as in other posts) is not good
either. A line with only whitespace and nothing else probably also should
be considered empty, and the above takes care of that.
However, I think there is a bug in the comment: it should be "this is NOT an
emptyLine."
- mfg
More information about the Python-list
mailing list