Message863
A file objects read() function does not seem to work
correctly after using the peek() function. For
instance consider the following python code used on a
file containing nothing but "Hello World":
>>> f=open(r'C:\temp.txt')
>>> f.read()
'Hello World'
>>> f.seek(0)
>>> f.read()
'Hello World'
The jython version on the other hand:
>>> f=open(r'C:\temp.txt')
>>> f.read()
'Hello World'
>>> f.seek(0)
>>> f.read()
''
It always outputs an empty string after a seek is called.
readlines() seems to work correctly:
>>> f=open(r'C:\temp.txt')
>>> f.readlines()
['Hello World']
>>> f.seek(0)
>>> f.readlines()
['Hello World']
A possible quick fix could just replace read with a
call to readlines and join the results with newline
characters. This should also fix the already posted
problem with read and readlines not working together.
BTW, I'm using Jython 2.1 on java1.4.1_01 |
|
| Date |
User |
Action |
Args |
| 2008-02-20 17:17:16 | admin | link | issue805725 messages |
| 2008-02-20 17:17:16 | admin | create | |
|