[Python-checkins] cpython (2.7): #15269: document dircmp.left and right.

r.david.murray python-checkins at python.org
Wed Aug 15 03:51:27 CEST 2012


http://hg.python.org/cpython/rev/e64d4518b23c
changeset:   78582:e64d4518b23c
branch:      2.7
parent:      78577:0dbdaa0ff648
user:        R David Murray <rdmurray at bitdance.com>
date:        Tue Aug 14 21:50:38 2012 -0400
summary:
  #15269: document dircmp.left and right.

Based on patch by Chris Jerdonek.

files:
  Doc/library/filecmp.rst |  25 +++++++++++++++++++++++++
  1 files changed, 25 insertions(+), 0 deletions(-)


diff --git a/Doc/library/filecmp.rst b/Doc/library/filecmp.rst
--- a/Doc/library/filecmp.rst
+++ b/Doc/library/filecmp.rst
@@ -106,6 +106,16 @@
    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*.
@@ -168,3 +178,18 @@
 
       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)
+

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list