How to bypass Windows 'cooking' the I/O? (One more time, please) II

Iain King iainking at gmail.com
Mon Jul 7 11:56:01 CEST 2008


On Jul 7, 10:18 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Mon, 07 Jul 2008 01:03:10 -0700, norseman <norse... at hughes.net>
> declaimed the following in comp.lang.python:
>
>
>
> >  > Normal file I/O sequence:
>
> >  > fp = open(target, 'wb')
>
> >  > fp.seek(-1, 2)
>
> >  > fp.write(record)
>
> >    Except it doesn't do that in Windows. See below.
>
>         I wouldn't expect that sequence to work on any system... The "w"
> implies "create new file, or truncate existing file to 0-bytes, then
> write data to it" -- with no seeking permitted. You must include the "+"
> to do seeking, and if you want to retain the existing file contents you
> probably need to open with "a+" ("a" for append).
>
>         The rest of your situation I won't touch. Other than to wonder why
> the situation hasn't hit any of the various database servers which must
> be operating in binary mode, and perform lots of seeking... Surely
> somewhere out someone else must have encountered a seek crossing an
> apparent <cr><eof> mark (which isn't a normal Windows sequence anyway --
> since Windows uses <cr><lf> for EOL, I'd have expected to see a problem
> if backing over a <cr><lf><eof>)
> --
>         Wulfraed        Dennis Lee Bieber               KD6MOG
>         wlfr... at ix.netcom.com              wulfr... at bestiaria.com
>                 HTTP://wlfraed.home.netcom.com/
>         (Bestiaria Support Staff:               web-a... at bestiaria.com)
>                 HTTP://www.bestiaria.com/


lol @ op not finding the answer to his question in the archives, then
being answered again by someone who doesn't let his answer go in the
archive.  How useful.



More information about the Python-list mailing list