[Tutor] file eats first character, film at 11

Sean 'Shaleh' Perry shalehperry@attbi.com
Sat Jun 14 14:31:01 2003


On Saturday 14 June 2003 09:41, Kirk Bailey wrote:
> ok, I wrote a program to strip out the ms-dos CRLF charpair, replacing with
> a single \n char. Works fine.
>

sorry did not look long enough to diagnose your problem.  However, I would 
like to make a comment on how you accomplish your task.

You risk data loss if you use one of the strip() family to eat the CR-LF 
pairs.  When?  Consider a file that has trailing whitespace for some reason.  
rstrip() will eat them right along with the CR-LF.

Now you (or someone else) may be saying "bah, so what?".  A proper file filter 
should only change what is must and return the EXACT same file back to the 
user.  They may have a very good reason for why each line ends with a tab.

I would recommend doing an explicit \r\n --> \n conversion.