how to delete or change...

Terry Reedy tjreedy at udel.edu
Mon Jul 22 11:41:35 EDT 2002


"Shagshag13" <shagshag13 at yahoo.fr> wrote in message
news:ahh5h2$sp205$1 at ID-146704.news.dfncis.de...
> > There are some unknown's here that would be helpful to know.  You
say
> > it's a text file but then talk about opening in binary.  Is it
ASCII?
>
> yes, it's an ascii file (i try to open it in binary to do bytes
operations instead of lines operations)

The (main? only?) difference between text and binary mode on Windows
is conversion between \r\n and \n (and none on *nix).

> > Also, you say when you tried the binary seek you got an I/O error.
> > Was there anything informative about that error that you can post?
>
> >>> f2 = file('d:/test.txt', 'rwb')
> >>> f2.seek(-5, 2)
> >>> f2.read(5)
> 'TUR\n'
> >>> f2.seek(-5, 2)
> >>> f2.write('new')
> Traceback (most recent call last):
>   File "<pyshell#99>", line 1, in ?
>     f2.write('new')
> IOError: (0, 'Error')

Not helpful at all.  What OS and compiler?  Standard distibution or
one you compiled?  Is your disk full?  Did you try 'rw' mode? Or just
'w'?

TJR






More information about the Python-list mailing list