This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients
Date 2006-01-03.01:02:58
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=31435

BTW, the standard actually says:

    and input shall not be directly followed by output
    without an intervening call to a file positioning
    function, unless the input operation encounters
    end-of-file.

In your f.read() + f.write() example, that doesn't happen. 
It _would_ happen if the sequence were f.read() + f.read() +
f.write() instead.  It's the second f.read() that
"encounters end-of-file".  The first f.read() merely reads
_up to_ EOF, leaving the file pointer _at_ EOF.

On Windows, that appears to work fine, too:

C:\Code>echo abc > foo
C:\Code>\python24\python.exe
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit
(Intel)] on win32
...
>>> f = open('foo', 'r+b')
>>> f.read()
'abc \r\n'
>>> f.read() # _this_ read "encounters EOF"
''
>>> f.write('xyz')
>>> f.seek(0)
>>> f.read()
'abc \r\nxyz'
>>>
History
Date User Action Args
2007-08-23 14:37:04adminlinkissue1394612 messages
2007-08-23 14:37:04admincreate