f.seek() unwanted output
python.list at tim.thechases.com
Mon Jan 5 15:13:30 CET 2009
> I'm having trouble with a script that is printing the output of f.seek
> I have a file in memory.
> when i try f.seek(0) #or any other value in f.tell()
> it gives me 0 as output:
> the following script illustrates my 'problem'
>>>> for a in range(10):
You're seeing an artifact of the command-line (evidenced by your
">>>" before your command). Just like
returns output...the Python console prints the output while a
script (saved to the disk) doesn't.
Try putting your test in foo.py and running that -- you'll notice
that it doesn't echo back the numbers as you describe.
The behavior seems to vary. In my Python2.4, seek() for
file/cStringIO/StringIO objects returns None with each.
Whichever version (or object-type) you're using seems to return
its input offset as its output.
More information about the Python-list