[Tutor] Tutor Digest, Vol 38, Issue 10

Jay Mutter III jmutter at uakron.edu
Fri Apr 6 10:46:24 CEST 2007


>
>
> "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.
>
> Can you try printing the string repr just before the test.
> Or even the last 6 characters:
>
> print repr(line[-6:])
> if line.endswith('No: \n')
>    line = line.strip()
>

Alan using your suggestion with the code aove here is the print out:

jay-mutter-iiis-computer:~/documents/ToBePrinted jlm1$ python test.py
'andal\r'
'  No.\r'
' Dor-\r'
'  14;\r'
'315 ;\r'
'  No.\r'
'utton\r'
'H'

Which appears to me to have 2 lines ending with No. where

  the LF should be removed and the next line would be on the same line

Again thanks for the help/suggestions

> See if that helps narrow down the cause...
>
>> This is an imac running python 2.3.5 under OS-X 10.4.9
>
> Shouldn't make any odds.
>
> Weird,
>
> Alan G.



More information about the Tutor mailing list