Module FileImpl


[Contents] [Prev] [Next]
Table of Contents

Overview

This module provides an implementation of the FileAPI.File interface that can be used to wrap an arbitrary file-like object.

Classes

This module defines the following classes:

FileWrapper(openfunc)
Implements the FileAPI.File interface. The argument is a function from a mode (e.g. 'r' or 'w') to a file-like object.

For example, the following function can be used to wrap a regular Python file object in a FileWrapper. Assume that the FileWrapper is created in an environment where the variable path specifies the file to be opened.

fw = FileWrapper(lambda mode, path=path: open(path, mode))

FileWrapper Objects

Instances of the FileWrapper class have the following methods. These methods raise FileAPI.FileIOError for errors, not the builtin IOError exception.

open(mode)
close()
flush()
read(size : integer) -> string
readline() -> string
readlines() -> list of string
seek(offset : integer, whence : 0, 1, 2)
write(text : string)
writelines(lines : list of string)
See the FileAPI.File documentation for a description of these methods.

Table of Contents

[Contents] [Prev] [Next]
Copyright © 1998 by the Corporation for National Research Initiatives.