file read, binary or text mode

Guyon Morée gumuz at NO_looze_SPAM.net
Fri Sep 24 08:10:16 EDT 2004


ok, i have huffman encoding code.

this is actually build for text, but because python can also read a binary
file as a string, this applies equally well :)

but, i was just wondering if this gives any problems if I use text-mode read
for the binary files and vice versa.

If I undertand correctly now, using binary mode is _always_ save, right?


"Peter Hansen" <peter at engcorp.com> wrote in message
news:MaqdnVoFl5tkmsncRVn-uQ at powergate.ca...
> Guyon Morée wrote:
> > what is the difference?
> >
> > if I open a text file in binary (rb) mode, it doesn't matter... the
read()
> > output is the same.
>
> If you are on Linux that's the case...  or under other
> conditions.  Maybe describing your platform and showing
> an example of what you're trying to do would be helpful.
>
> -Peter





More information about the Python-list mailing list