reading/writing files in windows

Peter Hansen peter at engcorp.com
Tue Jun 10 13:47:14 EDT 2003


sameer wrote:
> 
> why would it need to be in binary mode?  

Because mixing text and binary mode under Windows can cause all sorts
of trouble with line termination and obviously you are having problems
with line termination so I was asking you to verify that you are at
least use the same mode for each part of the process.

What happens if you don't edit the file with Notepad?  Why are you
editing the file with Notepad?  Can you produce a much smaller example
program which still demonstrates the problem, preferably one that 
uses only five or ten lines and doesn't have a lot of distracting
cruft that has no bearing on the problem at hand?

> I create all files in 'a'
> append mode.  All my code reads the file only in 'r' mode.  By
> "jumbled" I you simply mean the lines are all joined together, as
> though there were no linebreaks at all.

At what point do the files appear to be corrupted?  You say you
are editing in Notepad, then saving, so presumably up until that
point everything looks okay?  Where do you notice the problem 
first arising?  In the input routine laboriously called
_extract_published_retrieved_email_object(), or elsewhere?  

Perhaps at the point it writes "raw message is >>>"?  You
don't appear to actually output anything anywhere else, so I
can't tell what you mean.

> the code that generates the contents of the file

Sorry, I can't make head nor tails of what you're actually trying
to do.  Perhaps someone else with more patience will be willing
to try to decipher it, or perhaps you can take a bit more time to
carefully describe the missing detail.

-Peter




More information about the Python-list mailing list