summaryrefslogtreecommitdiff
path: root/Doc/library/filecmp.rst
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-08-14 21:45:25 -0400
committerR David Murray <rdmurray@bitdance.com>2012-08-14 21:45:25 -0400
commit7f848337263e5a703e3e15b5f6d123d3fde2b221 (patch)
tree7c2a5a8be1751e694617ac75d90ca63662dab62a /Doc/library/filecmp.rst
parent488cc36123dc57bbb261f97592ec89d02e019f9a (diff)
parent2b209cd78d5a36d63b00d0a4350b78aec7bc820b (diff)
downloadcpython-git-7f848337263e5a703e3e15b5f6d123d3fde2b221.tar.gz
Merge #15269: document dircmp.left and right, and add tests for them.
Patch by Chris Jerdonek.
Diffstat (limited to 'Doc/library/filecmp.rst')
-rw-r--r--Doc/library/filecmp.rst25
1 files changed, 25 insertions, 0 deletions
diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst
index 16dd100d34..add68a33ad 100644
--- a/Doc/library/filecmp.rst
+++ b/Doc/library/filecmp.rst
@@ -91,6 +91,16 @@ The :class:`dircmp` class
to compute are used.
+ .. attribute:: left
+
+ The directory *a*.
+
+
+ .. attribute:: right
+
+ The directory *b*.
+
+
.. attribute:: left_list
Files and subdirectories in *a*, filtered by *hide* and *ignore*.
@@ -154,3 +164,18 @@ The :class:`dircmp` class
A dictionary mapping names in :attr:`common_dirs` to :class:`dircmp`
objects.
+
+Here is a simplified example of using the ``subdirs`` attribute to search
+recursively through two directories to show common different files::
+
+ >>> from filecmp import dircmp
+ >>> def print_diff_files(dcmp):
+ ... for name in dcmp.diff_files:
+ ... print("diff_file %s found in %s and %s" % (name, dcmp.left,
+ ... dcmp.right))
+ ... for sub_dcmp in dcmp.subdirs.values():
+ ... print_diff_files(sub_dcmp)
+ ...
+ >>> dcmp = dircmp('dir1', 'dir2')
+ >>> print_diff_files(dcmp)
+