On this page
filecmp.dircmp
Prev: filecmp.cmpfiles | Up: filecmp
Rel: filecmp.clear_cache, filecmp.cmp, filecmp.cmpfiles
Ref: docs.python.org — filecmp.dircmp
Tags: #public #python3 #stdlib #filecmp
Import
import filecmp
from filecmp import dircmp
Signature & Overview
filecmp.dircmp(a, b, ignore=None, hide=None, *, shallow=True)
A class that manages the comparison of 2 directories.
Methods & Attributes
dircmp.phase0(self)—dircmp.phase0method/property.dircmp.phase1(self)—dircmp.phase1method/property.dircmp.phase2(self)—dircmp.phase2method/property.dircmp.phase3(self)—dircmp.phase3method/property.dircmp.phase4(self)—dircmp.phase4method/property.dircmp.phase4_closure(self)—dircmp.phase4_closuremethod/property.dircmp.report(self)—dircmp.reportmethod/property.dircmp.report_full_closure(self)—dircmp.report_full_closuremethod/property.dircmp.report_partial_closure(self)—dircmp.report_partial_closuremethod/property.
Usage
import filecmp
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as tmp:
l, r = Path(tmp) / "l", Path(tmp) / "r"
l.mkdir(); r.mkdir()
(l / "only.txt").write_text("1")
dc = filecmp.dircmp(l, r)
assert dc.left_only == ["only.txt"] and dc.right_only == []
Gotchas
- Attributes are computed lazily on first access (
left_only,right_only,same_files,diff_files,subdirs).
REPL Inspect
from filecmp import dircmp
help(dircmp)
Linked from
Related notes
- tuts/python3/stdlib_module/filecmp/clear_cache Linked here; links to this page; shared tags: #filecmp, #stdlib
- tuts/python3/stdlib_module/filecmp/cmp Linked here; links to this page; shared tags: #filecmp, #stdlib
- tuts/python3/stdlib_module/filecmp/cmpfiles Linked here; links to this page; shared tags: #filecmp, #stdlib
- tuts/python3/stdlib_module/filecmp Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib