Movatterモバイル変換


[0]ホーム

URL:


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:6.6 statvfsUp:6. Generic Operating SystemNext:6.7.1 The dircmp class

6.7filecmp -- File and Directory Comparisons

Thefilecmp module defines functions to compare files anddirectories, with various optional time/correctness trade-offs.

Thefilecmp module defines the following functions:

cmp(f1, f2[, shallow[, use_statcache]])
Compare the files namedf1 andf2, returning1 ifthey seem equal,0 otherwise.

Unlessshallow is given and is false, files with identicalos.stat() signatures are taken to be equal. Ifuse_statcache is given and is true,statcache.stat() will be called rather thenos.stat(); the default is to useos.stat().

Files that were compared using this function will not be compared againunless theiros.stat() signature changes. Note that usinguse_statcache true will cause the cache invalidation mechanism to fail -- the stale stat value will be used fromstatcache's cache.

Note that no external programs are called from this function, giving itportability and efficiency.

cmpfiles(dir1, dir2, common[, shallow[, use_statcache]])
Returns three lists of file names:match,mismatch,errors.match contains the list of files match in bothdirectories,mismatch includes the names of those that don't,anderrros lists the names of files which could not becompared. Files may be listed inerrors because the user maylack permission to read them or many other reasons, but always thatthe comparison could not be done for some reason.

Thecommon parameter is a list of file names found in both directories.Theshallow anduse_statcache parameters have the samemeanings and default values as forfilecmp.cmp().

Example:

>>> import filecmp>>> filecmp.cmp('libundoc.tex', 'libundoc.tex')1>>> filecmp.cmp('libundoc.tex', 'lib.tex')0


Subsections


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:6.6 statvfsUp:6. Generic Operating SystemNext:6.7.1 The dircmp class
Release 2.2.3, documentation updated on 30 May 2003.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2026 Movatter.jp