diff options
Diffstat (limited to 'Doc/lib/libfileinput.tex')
-rw-r--r-- | Doc/lib/libfileinput.tex | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Doc/lib/libfileinput.tex b/Doc/lib/libfileinput.tex index b6186dc..9e16f44 100644 --- a/Doc/lib/libfileinput.tex +++ b/Doc/lib/libfileinput.tex @@ -26,8 +26,10 @@ empty. If a filename is \code{'-'}, it is also replaced by it as the first argument to \function{input()}. A single file name is also allowed. -All files are opened in text mode. If an I/O error occurs during -opening or reading a file, \exception{IOError} is raised. +All files are opened in text mode by default, but you can override this by +specifying the \var{mode} parameter in the call to \function{input()} +or \class{FileInput()}. If an I/O error occurs during opening or reading +a file, \exception{IOError} is raised. If \code{sys.stdin} is used more than once, the second and further use will return no lines, except perhaps for interactive use, or if it has @@ -44,12 +46,14 @@ is present. The following function is the primary interface of this module: \begin{funcdesc}{input}{\optional{files\optional{, - inplace\optional{, backup}}}} + inplace\optional{, backup\optional{, mode}}}}} Create an instance of the \class{FileInput} class. The instance will be used as global state for the functions of this module, and is also returned to use during iteration. The parameters to this function will be passed along to the constructor of the \class{FileInput} class. + + \versionchanged[Added the \var{mode} parameter]{2.5} \end{funcdesc} @@ -111,7 +115,7 @@ The class which implements the sequence behavior provided by the module is available for subclassing as well: \begin{classdesc}{FileInput}{\optional{files\optional{, - inplace\optional{, backup}}}} + inplace\optional{, backup\optional{, mode}}}}} Class \class{FileInput} is the implementation; its methods \method{filename()}, \method{fileno()}, \method{lineno()}, \method{fileline()}, \method{isfirstline()}, \method{isstdin()}, @@ -122,6 +126,12 @@ module is available for subclassing as well: which implements the sequence behavior. The sequence must be accessed in strictly sequential order; random access and \method{readline()} cannot be mixed. + + With \var{mode} you can specify which file mode will be passed to + \function{open()}. It must be one of \code{'r'}, \code{'rU'}, + \code{'U'} and \code{'rb'}. + + \versionchanged[Added the \var{mode} parameter]{2.5} \end{classdesc} \strong{Optional in-place filtering:} if the keyword argument |