summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-02-19 14:12:34 (GMT)
committerGeorg Brandl <georg@python.org>2006-02-19 14:12:34 (GMT)
commitc029f873cb170a5525ef78b00b3957e52be41cda (patch)
tree93fdedcfe2f51f18ecaa80ac0b13fe1d4eb7246c /Doc
parent67e9fb9d7afbd9935322420a7cadd4cb6538dcdf (diff)
downloadcpython-c029f873cb170a5525ef78b00b3957e52be41cda.zip
cpython-c029f873cb170a5525ef78b00b3957e52be41cda.tar.gz
cpython-c029f873cb170a5525ef78b00b3957e52be41cda.tar.bz2
Patch #1212287: fileinput.input() now has a mode parameter for
specifying the file mode input files should be opened with.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libfileinput.tex18
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