[issue16154] Some minor doc fixes in Doc/library

Terry J. Reedy report at bugs.python.org
Sun Oct 7 20:33:43 CEST 2012


Terry J. Reedy added the comment:

I consider some items to be errors. In any case, all current docs can be fixed. First, your questions as to what you did not fix.

fsum: I personally would add the import visibly, but at least add it hidden, as Chris suggested.

171 >>> from filecmp import dircmp
172 >>> def print_diff_files(dcmp):
173 ... for name in dcmp.diff_files:
174 ... print("diff_file %s found in %s and %s" % (name, dcmp.left,
175 ... dcmp.right))
176 ... for sub_dcmp in dcmp.subdirs.values():
177 ... print_diff_files(sub_dcmp)
178 ...
179 >>> dcmp = dircmp('dir1', 'dir2')
180 >>> print_diff_files(dcmp)

(copying from the repository view deletes whitespace)
The import and def should run and should be tested.
The last 2 lines should not be tested: add #doctest: SKIP to both.
(I gather that Sphinx will strip this.)

   >>> width = 5
   >>> for num in range(5,12):
   ...     for base in 'dXob':
   ...         print('{0:{width}{base}}'.format(num, base=base, width=width), end=' ')
   ...     print()
   ...
       5     5     5   101
       6     6     6   110
       7     7     7   111
       8     8    10  1000
       9     9    11  1001
      10     A    12  1010
      11     B    13  1011

I believe the problem here is the "end = ''" part. It puts a blank space at the end of each line, which got deleted when I pasted the above, which was cut from my local repository. Trailing blanks are *really* a problem and code that produces them is not a good example. I suggest changing width to 6, end to '', and adding '' to the beginning of each output line. It should then pass.

----------
type: enhancement -> behavior
versions: +Python 2.7, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16154>
_______________________________________


More information about the Python-bugs-list mailing list