Problem with f.seek(offset,whence)

[email protected] Wed, 20 Aug 2025 09:39:35 -0000
Newsgroups gmane.comp.python.tutor
Message-ID <[email protected]>
Dear list, 
surely it is an old question, but I did not find any answers.  

-- snip 
 f = open('test.txt','w+')
 f.write('0123456789')
10
 f.seek(2)
2
 f.seek(2,1)

-- snap 
results in the error message
     io.UnsupportedOperation: can't do nonzero cur-relative seeks

I do not know, what the problem is.  If you can place the cursor with f.seek(2) at an absolute position, 
it must be possible, to change its position relative (whence = 1) to 2+2 = 4.  

f.seek(0,2) functions (end of file), but not f.seek(-1,2) (same error).  

Do  you know, what's wrong?  The examples of the KI do not function as well.  

Regards Heiko
_______________________________________________
Tutor maillist  -  To unsubscribe send an email to [email protected]
To unsubscribe or change subscription options:
%(web_page_url)slistinfo/%(_internal_name)s