seek() tell()

Peter Hansen peter at engcorp.com
Wed Feb 5 21:36:34 EST 2003


Erik Max Francis wrote:
> 
> Peter Hansen wrote:
> 
> > I suspect the difference is because you've opened the file in
> > "text mode" under Windows.  If you just do fo = open('name', 'w')
> > it will be in text mode, where all linefeed characters (\n)
> > are converted to carriage-return/linefeed pairs, increasing
> > the size of the output by one byte per line.
> >
> > If you don't want this behaviour (but under Windows you probably
> > do), just open the file in "binary mode" using open('name,' 'wb).
> > For more information, read the friendly manual...
> 
> Presumably you mean "rb" or "wb+", since you can't seek and tell on
> files opened for write only.

You can do tell only, though, can't you?  I think that's all
the OP was trying to do.  If he also needed seek, then you're
quite right (or is that "write"? :-).

-Peter




More information about the Python-list mailing list