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

in fd •  5 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)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!