tkgcci avatar

Creating a file object named as os.fdopen(fd, *args, **kwargs)๐Ÿ’žโ˜ฃ

tkgcci

Published: 14 Dec 2019 โ€บ Updated: 14 Dec 2019Creating a file object named as os.fdopen(fd, *args, **kwargs)๐Ÿ’žโ˜ฃ

Creating a file object named as os.fdopen(fd, *args, **kwargs)๐Ÿ’žโ˜ฃ

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)

Leave Creating a file object named as os.fdopen(fd, *args, **kwargs)๐Ÿ’žโ˜ฃ to:

Written by

Read more #open posts


Best Posts From tkgcci

We have not curated any of tkgcci's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From tkgcci