On Tue, Jan 16, 2018 at 4:00 PM, Skip Montanaro
<[email protected]> wrote:
> I'd like to take advantage of the seekable() method of io.IOBase with
> existing open file objects, especially the standard in/out/err file
> objects.
io.open can open a file descriptor. If you don't use a duplicated FD
(os.dup), then you probably also want the option `closefd=False`. For
example:
$ cat test.py
import sys
import io
stdin = io.open(sys.stdin.fileno(), closefd=False)
print 'stdin seekable: %s' % stdin.seekable()
$ python test.py
stdin seekable: False
$ echo spam | python test.py
stdin seekable: False
$ python test.py < test.py
stdin seekable: True
--
https://mail.python.org/mailman/listinfo/python-list