From ac0333e1e117b7f61ed7ef1dbcdb6e515ada603b Mon Sep 17 00:00:00 2001 From: Andre Delfino Date: Tue, 15 Sep 2020 17:13:26 -0300 Subject: [PATCH] Fix all Python Cookbook links (#22205) --- Doc/faq/programming.rst | 2 +- Doc/howto/urllib2.rst | 2 +- Doc/library/bisect.rst | 2 +- Doc/library/collections.abc.rst | 2 +- Doc/library/collections.rst | 4 ++-- Doc/library/difflib.rst | 2 +- Doc/library/math.rst | 2 +- Doc/library/random.rst | 2 +- Doc/library/shelve.rst | 2 +- Doc/library/stdtypes.rst | 2 +- Doc/library/sys.rst | 2 +- Doc/tutorial/whatnow.rst | 2 +- Doc/whatsnew/3.2.rst | 4 ++-- Lib/collections/__init__.py | 2 +- Lib/heapq.py | 2 +- Lib/test/test_math.py | 2 +- Tools/peg_generator/pegen/sccutils.py | 4 ++-- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 66d210a55fa..eecbbf4a5c4 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -1141,7 +1141,7 @@ How do you remove duplicates from a list? See the Python Cookbook for a long discussion of many ways to do this: - https://code.activestate.com/recipes/52560/ + https://github.com/ActiveState/code/tree/master/recipes/Python/52560_Remove_duplicates/recipe-52560.py If you don't mind reordering the list, sort it and then scan from the end of the list, deleting duplicates as you go:: diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst index 046a88af62f..38623371fba 100644 --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -601,5 +601,5 @@ This document was reviewed and revised by John Lee. scripts with a localhost server, I have to prevent urllib from using the proxy. .. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe - `_. + `_. diff --git a/Doc/library/bisect.rst b/Doc/library/bisect.rst index 6bf7814b257..6666d55abe2 100644 --- a/Doc/library/bisect.rst +++ b/Doc/library/bisect.rst @@ -60,7 +60,7 @@ The following functions are provided: .. seealso:: `SortedCollection recipe - `_ that uses + `_ that uses bisect to build a full-featured collection class with straight-forward search methods and support for a key-function. The keys are precomputed to save unnecessary calls to the key function during searches. diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst index db0e25bb077..a6038098675 100644 --- a/Doc/library/collections.abc.rst +++ b/Doc/library/collections.abc.rst @@ -308,7 +308,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin: .. seealso:: - * `OrderedSet recipe `_ for an + * `OrderedSet recipe `_ for an example built on :class:`MutableSet`. * For more about ABCs, see the :mod:`abc` module and :pep:`3119`. diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index f538da5e1c9..a7d01b3f397 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -135,12 +135,12 @@ The class can be used to simulate nested scopes and is useful in templating. :attr:`~collections.ChainMap.parents` property. * The `Nested Contexts recipe - `_ has options to control + `_ has options to control whether writes and other mutations apply only to the first mapping or to any mapping in the chain. * A `greatly simplified read-only version of Chainmap - `_. + `_. :class:`ChainMap` Examples and Recipes diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst index aa08988c8b3..009b7976dff 100644 --- a/Doc/library/difflib.rst +++ b/Doc/library/difflib.rst @@ -633,7 +633,7 @@ If you want to know how to change the first sequence into the second, use work. * `Simple version control recipe - `_ for a small application + `_ for a small application built with :class:`SequenceMatcher`. diff --git a/Doc/library/math.rst b/Doc/library/math.rst index bbf64643ff5..f152c45a87a 100644 --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -123,7 +123,7 @@ Number-theoretic and representation functions For further discussion and two alternative approaches, see the `ASPN cookbook recipes for accurate floating point summation - `_\. + `_\. .. function:: gcd(*integers) diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 0cdf0a6ac4a..4e97b1dbad8 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -57,7 +57,7 @@ from sources provided by the operating system. `Complementary-Multiply-with-Carry recipe - `_ for a compatible alternative + `_ for a compatible alternative random number generator with a long period and comparatively simple update operations. diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst index f08c58179a2..a94255bbf69 100644 --- a/Doc/library/shelve.rst +++ b/Doc/library/shelve.rst @@ -75,7 +75,7 @@ Two additional methods are supported: .. seealso:: - `Persistent dictionary recipe `_ + `Persistent dictionary recipe `_ with widely supported storage formats and having the speed of native dictionaries. diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 0ffe7b7526f..2eee22c79af 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1404,7 +1404,7 @@ objects that compare equal might have different :attr:`~range.start`, .. seealso:: - * The `linspace recipe `_ + * The `linspace recipe `_ shows how to implement a lazy version of range suitable for floating point applications. diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index d201d7061f9..aa417ede402 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -679,7 +679,7 @@ always available. additional garbage collector overhead if the object is managed by the garbage collector. - See `recursive sizeof recipe `_ + See `recursive sizeof recipe `_ for an example of using :func:`getsizeof` recursively to find the size of containers and all their contents. diff --git a/Doc/tutorial/whatnow.rst b/Doc/tutorial/whatnow.rst index 3208201312b..38ce9f0a900 100644 --- a/Doc/tutorial/whatnow.rst +++ b/Doc/tutorial/whatnow.rst @@ -43,7 +43,7 @@ More Python resources: for download. Once you begin releasing code, you can register it here so that others can find it. -* https://code.activestate.com/recipes/langs/python/: The Python Cookbook is a +* https://github.com/ActiveState/code/tree/master/recipes/Python: The Python Cookbook is a sizable collection of code examples, larger modules, and useful scripts. Particularly notable contributions are collected in a book also titled Python Cookbook (O'Reilly & Associates, ISBN 0-596-00797-3.) diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst index 06bee9966c0..37bae34ce74 100644 --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -781,8 +781,8 @@ functools (Contributed by Raymond Hettinger and incorporating design ideas from Jim Baker, Miki Tebeka, and Nick Coghlan; see `recipe 498245 - `_\, `recipe 577479 - `_\, :issue:`10586`, and + `_\, `recipe 577479 + `_\, :issue:`10586`, and :issue:`10593`.) * The :func:`functools.wraps` decorator now adds a :attr:`__wrapped__` attribute diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 5d75501645f..f4da9d0cefd 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -574,7 +574,7 @@ class Counter(dict): # http://en.wikipedia.org/wiki/Multiset # http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html # http://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm - # http://code.activestate.com/recipes/259174/ + # https://github.com/ActiveState/code/tree/master/recipes/Python/259174_bag_collection_class/recipe-259174.py # Knuth, TAOCP Vol. II section 4.6.3 def __init__(self, iterable=None, /, **kwds): diff --git a/Lib/heapq.py b/Lib/heapq.py index fabefd87f8b..5895562db41 100644 --- a/Lib/heapq.py +++ b/Lib/heapq.py @@ -456,7 +456,7 @@ def merge(*iterables, key=None, reverse=False): # 2) Made multiple passes over the data. # 3) Made more comparisons in common cases (small k, large n, semi-random input). # See the more detailed comparison of approach at: -# http://code.activestate.com/recipes/577573-compare-algorithms-for-heapqsmallest +# https://github.com/ActiveState/code/tree/master/recipes/Python/577573_Compare_algorithms/recipe-577573.py def nsmallest(n, iterable, key=None): """Find the n smallest elements in a dataset. diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 4d62eb1b119..f5283c5e0dc 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -611,7 +611,7 @@ class MathTests(unittest.TestCase): def msum(iterable): """Full precision summation. Compute sum(iterable) without any intermediate accumulation of error. Based on the 'lsum' function - at http://code.activestate.com/recipes/393090/ + at https://github.com/ActiveState/code/tree/master/recipes/Python/393090_Binary_floating_point_summatiaccurate_full/recipe-393090.py """ tmant, texp = 0, 0 diff --git a/Tools/peg_generator/pegen/sccutils.py b/Tools/peg_generator/pegen/sccutils.py index 1f0586bb2f7..0c295196607 100644 --- a/Tools/peg_generator/pegen/sccutils.py +++ b/Tools/peg_generator/pegen/sccutils.py @@ -18,7 +18,7 @@ def strongly_connected_components( exactly once; vertices not part of a SCC are returned as singleton sets. - From http://code.activestate.com/recipes/578507/. + From https://github.com/ActiveState/code/tree/master/recipes/Python/578507_Strongly_connected_components_directed/recipe-578507.py. """ identified: Set[str] = set() stack: List[str] = [] @@ -81,7 +81,7 @@ def topsort( {B, C} {A} - From http://code.activestate.com/recipes/577413/. + From https://github.com/ActiveState/code/tree/master/recipes/Python/577413_Topological_Sort/recipe-577413.py. """ # TODO: Use a faster algorithm? for k, v in data.items():