Creating a file object named as os.fdopen(fd, *args, **kwargs)💞☣

in #fd5 years ago (edited)

Creating a file object


The file system encoding must ensure that everything is successfully decoded to 128 bytes or less. If the file system encoding does not guarantee this, the API function raises a UnicodeError.

Connects to file descriptor fd and returns an open file object. This is an alias for the built-in function open () and takes the same arguments. The only difference is that the first argument to fdopen () must always be an integer.

20181120_154941_319.jpg

tkgcci

# py/cpython/blob/master/Lib/os.py
# Supply os.fdopen()
def fdopen(fd, *args, **kwargs):
  if not isinstance(fd, int):
    raise TypeError("invalid fd type (%s, expected integer)" % type(fd))
  import io
  return io.open(fd, *args, **kwargs)

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.029
BTC 57589.28
ETH 3109.28
USDT 1.00
SBD 2.37