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)

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center