Message27208
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'
>>>
|
|
Date |
User |
Action |
Args |
2007-08-23 14:37:04 | admin | link | issue1394612 messages |
2007-08-23 14:37:04 | admin | create | |
|