Movatterモバイル変換


[0]ホーム

URL:


Up one LevelPython Library ReferenceContentsModule IndexIndex

11.5filecmp -- 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])
Compare the files namedf1 andf2, returningTrue ifthey seem equal,False otherwise.

Unlessshallow is given and is false, files with identicalos.stat() signatures are taken to be equal.

Files that were compared using this function will not be compared againunless theiros.stat() signature changes.

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

cmpfiles(dir1, dir2, common[, shallow])
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 parameter has the samemeaning and default value as forfilecmp.cmp().

Example:

>>> import filecmp>>> filecmp.cmp('libundoc.tex', 'libundoc.tex')True>>> filecmp.cmp('libundoc.tex', 'lib.tex')False



Subsections


Up one LevelPython Library ReferenceContentsModule IndexIndex

Release 2.5.2, documentation updated on 21st February, 2008.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2025 Movatter.jp