Index: Doc/library/difflib.rst =================================================================== --- Doc/library/difflib.rst (revision 87951) +++ Doc/library/difflib.rst (working copy) @@ -159,7 +159,7 @@ >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n'] >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n'] >>> for line in context_diff(s1, s2, fromfile='before.py', tofile='after.py'): - ... sys.stdout.write(line) # doctest: +NORMALIZE_WHITESPACE + ... print(line, end='') # doctest: +NORMALIZE_WHITESPACE *** before.py --- after.py *************** @@ -197,7 +197,7 @@ >>> import keyword >>> get_close_matches('wheel', keyword.kwlist) ['while'] - >>> get_close_matches('apple', keyword.kwlist) + >>> get_close_matches('apple', keyword.kwlist, cutoff=0.7) [] >>> get_close_matches('accept', keyword.kwlist) ['except'] @@ -292,7 +292,7 @@ >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n'] >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n'] >>> for line in unified_diff(s1, s2, fromfile='before.py', tofile='after.py'): - ... sys.stdout.write(line) # doctest: +NORMALIZE_WHITESPACE + ... print(line, end='') # doctest: +NORMALIZE_WHITESPACE --- before.py +++ after.py @@ -1,4 +1,4 @@ Index: Doc/library/collections.rst =================================================================== --- Doc/library/collections.rst (revision 87951) +++ Doc/library/collections.rst (working copy) @@ -120,6 +120,7 @@ >>> c = Counter(a=4, b=2, c=0, d=-2) >>> d = Counter(a=1, b=2, c=3, d=4) >>> c.subtract(d) + >>> c Counter({'a': 3, 'b': 0, 'c': -3, 'd': -6}) .. versionadded:: 3.2 @@ -544,7 +545,7 @@ ... d[k].add(v) ... >>> list(d.items()) - [('blue', set([2, 4])), ('red', set([1, 3]))] + [('blue', {2, 4}), ('red', {1, 3})] :func:`namedtuple` Factory Function for Tuples with Named Fields @@ -587,7 +588,7 @@ .. doctest:: - :options: +NORMALIZE_WHITESPACE + :options: +NORMALIZE_WHITESPACE,+REPORT_UDIFF >>> # Basic example >>> Point = namedtuple('Point', 'x y') @@ -626,15 +627,16 @@ 'Return a new Point object replacing specified fields with new values' result = _self._make(map(kwds.pop, ('x', 'y'), _self)) if kwds: - raise ValueError('Got unexpected field names: %r' % list(kwds.keys())) + raise ValueError('Got unexpected field names: %r' % kwds.keys()) return result def __getnewargs__(self): - 'Return self as a plain tuple. Used by copy and pickle.' + 'Return self as a plain tuple. Used by copy and pickle.' return tuple(self) x = _property(_itemgetter(0), doc='Alias for field number 0') y = _property(_itemgetter(1), doc='Alias for field number 1') + >>> p = Point(11, y=22) # instantiate with positional or keyword arguments >>> p[0] + p[1] # indexable like the plain tuple (11, 22) Index: Lib/difflib.py =================================================================== --- Lib/difflib.py (revision 87949) +++ Lib/difflib.py (working copy) @@ -530,7 +530,7 @@ non_adjacent.append( (la, lb, 0) ) self.matching_blocks = non_adjacent - return map(Match._make, self.matching_blocks) + return [Match._make(b) for b in self.matching_blocks] def get_opcodes(self): """Return list of 5-tuples describing how to turn a into b. Index: Lib/collections.py =================================================================== --- Lib/collections.py (revision 87949) +++ Lib/collections.py (working copy) @@ -291,34 +291,34 @@ argtxt = repr(field_names).replace("'", "")[1:-1] # tuple repr without parens or quotes reprtxt = ', '.join('%s=%%r' % name for name in field_names) template = '''class %(typename)s(tuple): - '%(typename)s(%(argtxt)s)' \n - __slots__ = () \n - _fields = %(field_names)r \n + '%(typename)s(%(argtxt)s)'\n + __slots__ = ()\n + _fields = %(field_names)r\n def __new__(_cls, %(argtxt)s): - 'Create new instance of %(typename)s(%(argtxt)s)' - return _tuple.__new__(_cls, (%(argtxt)s)) \n + 'Create a new instance of %(typename)s(%(argtxt)s)' + return _tuple.__new__(_cls, (%(argtxt)s))\n @classmethod def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new %(typename)s object from a sequence or iterable' result = new(cls, iterable) if len(result) != %(numfields)d: raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result)) - return result \n + return result\n def __repr__(self): 'Return a nicely formatted representation string' - return self.__class__.__name__ + '(%(reprtxt)s)' %% self \n + return self.__class__.__name__ + '(%(reprtxt)s)' %% self\n def _asdict(self): 'Return a new OrderedDict which maps field names to their values' - return OrderedDict(zip(self._fields, self)) \n + return OrderedDict(zip(self._fields, self))\n def _replace(_self, **kwds): 'Return a new %(typename)s object replacing specified fields with new values' result = _self._make(map(kwds.pop, %(field_names)r, _self)) if kwds: raise ValueError('Got unexpected field names: %%r' %% kwds.keys()) - return result \n + return result\n def __getnewargs__(self): 'Return self as a plain tuple. Used by copy and pickle.' - return tuple(self) \n\n''' % locals() + return tuple(self)\n\n''' % locals() for i, name in enumerate(field_names): template += " %s = _property(_itemgetter(%d), doc='Alias for field number %d')\n" % (name, i, i) if verbose: