Suppose somebody passes me an open file handle. What's the right way to tell
if it is seekable in Python 2?

I see that stdin has a seek and tell method, but they raise:

py> sys.stdin.tell()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 29] Illegal seek

Are seek and tell guaranteed to exist on all files?

Is there some other way to tell whether the file supports seeking other than
to try it and see?


(In Python 3, files have a seekable method.)


-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to