GNU Info

Info Node: (python2.1-lib.info)File Object Creation

(python2.1-lib.info)File Object Creation


Next: File Descriptor Operations Prev: Process Parameters Up: os
Enter node , (file) or (file)node

File Object Creation
--------------------

These functions create new file objects.

`fdopen(fd[, mode[, bufsize]])'
     Return an open file object connected to the file descriptor FD.
     The MODE and BUFSIZE arguments have the same meaning as the
     corresponding arguments to the built-in `open()' function.
     Availability: Macintosh, UNIX, Windows.

`popen(command[, mode[, bufsize]])'
     Open a pipe to or from COMMAND.  The return value is an open file
     object connected to the pipe, which can be read or written
     depending on whether MODE is `'r'' (default) or `'w''.  The
     BUFSIZE argument has the same meaning as the corresponding
     argument to the built-in `open()' function.  The exit status of
     the command (encoded in the format specified for `wait()') is
     available as the return value of the `close()' method of the file
     object, except that when the exit status is zero (termination
     without errors), `None' is returned.  Availability: UNIX, Windows.

     _Changed in Python version 2.0_

`tmpfile()'
     Return a new file object opened in update mode (`w+').  The file
     has no directory entries associated with it and will be
     automatically deleted once there are no file descriptors for the
     file.  Availability: UNIX.

For each of these `popen()' variants, if BUFSIZE is specified, it
specifies the buffer size for the I/O pipes.  MODE, if provided, should
be the string `'b'' or `'t''; on Windows this is needed to determine
whether the file objects should be opened in binary or text mode.  The
default value for MODE is `'t''.

`popen2(cmd[, mode[, bufsize]])'
     Executes CMD as a sub-process.  Returns the file objects
     `(CHILD_STDIN, CHILD_STDOUT)'.  Availability: UNIX, Windows.
     _Added in Python version 2.0_

`popen3(cmd[, mode[, bufsize]])'
     Executes CMD as a sub-process.  Returns the file objects
     `(CHILD_STDIN, CHILD_STDOUT, CHILD_STDERR)'.  Availability: UNIX,
     Windows.  _Added in Python version 2.0_

`popen4(cmd[, mode[, bufsize]])'
     Executes CMD as a sub-process.  Returns the file objects
     `(CHILD_STDIN, CHILD_STDOUT_AND_STDERR)'.  Availability: UNIX,
     Windows.  _Added in Python version 2.0_

This functionality is also available in the `popen2' module using
functions of the same names, but the return values of those functions
have a different order.


automatically generated by info2www version 1.2.2.9