[Tutor] Tutor Digest, Vol 38, Issue 2
Rikard Bosnjakovic
rikard.bosnjakovic at gmail.com
Thu Apr 5 18:55:44 CEST 2007
Jay, PLEASE shorten your posts by removing all unnecessary quoting.
On 4/5/07, Jay Mutter III <jmutter at uakron.edu> wrote:
> Whether I attempt to just strip the string or attempt to
>
> if line.endswith('No.\r'):
> line = line.rstrip()
>
> It doesn't work.
That's because you assume the linefeeds to be \r only. If you really
want to strip endings on strings ending with "No.", then do this
workaround:
foo = line.rstrip()
if foo.endswith("No."):
line = foo
Never assume line breaks to be of any type, because there are four of
them: \n, \r, \n\r, \r\n. It would be a waste of code to check for all
four, kind of reimplementing the wheel again.
--
- Rikard - http://bos.hack.org/cv/
More information about the Tutor
mailing list