blob: 3d56e307459014c10460d1de259fc9945fc139c4 [file] [log] [blame]
Fred Drakec7b5b3c1999-10-29 17:23:15 +00001\section{\module{filecmp} ---
2 File Comparisons}
3
4\declaremodule{standard}{filecmp}
5\sectionauthor{Moshe Zadka}{mzadka@geocities.com}
6\modulesynopsis{Compare files efficiently.}
7
8The \module{filecmp} module defines a function to compare files, taking all
9sort of short-cuts to make it a highly efficient operation.
10
11The \module{filecmp} module defines the following function:
12
13\begin{funcdesc}{cmp}{f1, f2\optional{, shallow\optional{, use_statcache}}}
14Compare the files named \var{f1} and \var{f2}, returning \code{1}
15if they seem equal, \code{0} otherwise.
16
17Unless \var{shallow} is given and is false, files with identical
18\function{os.stat()} signatures are taken to be equal. If
19\var{use_statcache} is given and is true,
20\function{statcache.stat()} will be called rather then \var{os.stat()}.
21
22Files that were compared using this function will not be compared again
23unless their \function{os.stat()} signature changes. Note that using
24\var{use_statcache} true will cause the cache invalidation mechanism to
25fail --- the stale stat value will be used from \refmodule{statcache}'s
26cache.
27
28Note that no external programs are called from this module giving it
29portability and efficiency.
30\end{funcdesc}
31
32Example:
33
34\begin{verbatim}
35>>> import filecmp
36>>> filecmp.cmp('libundoc.tex', 'libundoc.tex')
371
38>>> filecmp.cmp('libundoc.tex', 'lib.tex')
390
40\end{verbatim}