Revert "Fix all Python Cookbook links (#22205)" (GH-22424)

This commit reverts commit ac0333e1e1 as the original links are working again and they provide extended features such as comments and alternative versions.
This commit is contained in:
Andre Delfino 2020-09-26 21:47:25 -03:00 committed by GitHub
parent 2afd1751dd
commit e8a2076e14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 20 additions and 20 deletions

View File

@ -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: See the Python Cookbook for a long discussion of many ways to do this:
https://github.com/ActiveState/code/tree/master/recipes/Python/52560_Remove_duplicates/recipe-52560.py https://code.activestate.com/recipes/52560/
If you don't mind reordering the list, sort it and then scan from the end of the If you don't mind reordering the list, sort it and then scan from the end of the
list, deleting duplicates as you go:: list, deleting duplicates as you go::

View File

@ -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 scripts with a localhost server, I have to prevent urllib from using
the proxy. the proxy.
.. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe .. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/456195_urrlib2_opener_SSL_proxy_CONNECT/recipe-456195.py>`_. <https://code.activestate.com/recipes/456195/>`_.

View File

@ -60,7 +60,7 @@ The following functions are provided:
.. seealso:: .. seealso::
`SortedCollection recipe `SortedCollection recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/577197_SortedCollection/recipe-577197.py>`_ that uses <https://code.activestate.com/recipes/577197-sortedcollection/>`_ that uses
bisect to build a full-featured collection class with straight-forward search 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 methods and support for a key-function. The keys are precomputed to save
unnecessary calls to the key function during searches. unnecessary calls to the key function during searches.

View File

@ -308,7 +308,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
.. seealso:: .. seealso::
* `OrderedSet recipe <https://github.com/ActiveState/code/tree/master/recipes/Python/576694_OrderedSet/recipe-576694.py>`_ for an * `OrderedSet recipe <https://code.activestate.com/recipes/576694/>`_ for an
example built on :class:`MutableSet`. example built on :class:`MutableSet`.
* For more about ABCs, see the :mod:`abc` module and :pep:`3119`. * For more about ABCs, see the :mod:`abc` module and :pep:`3119`.

View File

@ -135,12 +135,12 @@ The class can be used to simulate nested scopes and is useful in templating.
:attr:`~collections.ChainMap.parents` property. :attr:`~collections.ChainMap.parents` property.
* The `Nested Contexts recipe * The `Nested Contexts recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/577434_Nested_contexts__chamapping/recipe-577434.py>`_ has options to control <https://code.activestate.com/recipes/577434/>`_ has options to control
whether writes and other mutations apply only to the first mapping or to whether writes and other mutations apply only to the first mapping or to
any mapping in the chain. any mapping in the chain.
* A `greatly simplified read-only version of Chainmap * A `greatly simplified read-only version of Chainmap
<https://github.com/ActiveState/code/tree/master/recipes/Python/305268_Chained_map_lookups/recipe-305268.py>`_. <https://code.activestate.com/recipes/305268/>`_.
:class:`ChainMap` Examples and Recipes :class:`ChainMap` Examples and Recipes

View File

@ -633,7 +633,7 @@ If you want to know how to change the first sequence into the second, use
work. work.
* `Simple version control recipe * `Simple version control recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/576729_Simple_Version_Control/recipe-576729.py>`_ for a small application <https://code.activestate.com/recipes/576729/>`_ for a small application
built with :class:`SequenceMatcher`. built with :class:`SequenceMatcher`.

View File

@ -123,7 +123,7 @@ Number-theoretic and representation functions
For further discussion and two alternative approaches, see the `ASPN cookbook For further discussion and two alternative approaches, see the `ASPN cookbook
recipes for accurate floating point summation recipes for accurate floating point summation
<https://github.com/ActiveState/code/tree/master/recipes/Python/393090_Binary_floating_point_summatiaccurate_full/recipe-393090.py>`_\. <https://code.activestate.com/recipes/393090/>`_\.
.. function:: gcd(*integers) .. function:: gcd(*integers)

View File

@ -57,7 +57,7 @@ from sources provided by the operating system.
`Complementary-Multiply-with-Carry recipe `Complementary-Multiply-with-Carry recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/576707_Long_period_random_number/recipe-576707.py>`_ for a compatible alternative <https://code.activestate.com/recipes/576707/>`_ for a compatible alternative
random number generator with a long period and comparatively simple update random number generator with a long period and comparatively simple update
operations. operations.

View File

@ -75,7 +75,7 @@ Two additional methods are supported:
.. seealso:: .. seealso::
`Persistent dictionary recipe <https://github.com/ActiveState/code/tree/master/recipes/Python/576642_Persistent_dict_multiple_standard_file/recipe-576642.py>`_ `Persistent dictionary recipe <https://code.activestate.com/recipes/576642/>`_
with widely supported storage formats and having the speed of native with widely supported storage formats and having the speed of native
dictionaries. dictionaries.

View File

@ -1404,7 +1404,7 @@ objects that compare equal might have different :attr:`~range.start`,
.. seealso:: .. seealso::
* The `linspace recipe <https://github.com/ActiveState/code/tree/master/recipes/Python/579000_Equallyspaced_numbers_linspace/recipe-579000.py>`_ * The `linspace recipe <http://code.activestate.com/recipes/579000/>`_
shows how to implement a lazy version of range suitable for floating shows how to implement a lazy version of range suitable for floating
point applications. point applications.

View File

@ -679,7 +679,7 @@ always available.
additional garbage collector overhead if the object is managed by the garbage additional garbage collector overhead if the object is managed by the garbage
collector. collector.
See `recursive sizeof recipe <https://github.com/ActiveState/code/tree/master/recipes/Python/577504_Compute_Memory_footprint_object_its/recipe-577504.py>`_ See `recursive sizeof recipe <https://code.activestate.com/recipes/577504>`_
for an example of using :func:`getsizeof` recursively to find the size of for an example of using :func:`getsizeof` recursively to find the size of
containers and all their contents. containers and all their contents.

View File

@ -43,7 +43,7 @@ More Python resources:
for download. Once you begin releasing code, you can register it here so that for download. Once you begin releasing code, you can register it here so that
others can find it. others can find it.
* https://github.com/ActiveState/code/tree/master/recipes/Python: The Python Cookbook is a * https://code.activestate.com/recipes/langs/python/: The Python Cookbook is a
sizable collection of code examples, larger modules, and useful scripts. sizable collection of code examples, larger modules, and useful scripts.
Particularly notable contributions are collected in a book also titled Python Particularly notable contributions are collected in a book also titled Python
Cookbook (O'Reilly & Associates, ISBN 0-596-00797-3.) Cookbook (O'Reilly & Associates, ISBN 0-596-00797-3.)

View File

@ -781,8 +781,8 @@ functools
(Contributed by Raymond Hettinger and incorporating design ideas from Jim (Contributed by Raymond Hettinger and incorporating design ideas from Jim
Baker, Miki Tebeka, and Nick Coghlan; see `recipe 498245 Baker, Miki Tebeka, and Nick Coghlan; see `recipe 498245
<https://github.com/ActiveState/code/tree/master/recipes/Python/498245_LRU_and_LFU_cache_decorators/recipe-498245.py>`_\, `recipe 577479 <https://code.activestate.com/recipes/498245>`_\, `recipe 577479
<https://github.com/ActiveState/code/tree/master/recipes/Python/577479_Simple_caching_decorator/recipe-577479.py>`_\, :issue:`10586`, and <https://code.activestate.com/recipes/577479>`_\, :issue:`10586`, and
:issue:`10593`.) :issue:`10593`.)
* The :func:`functools.wraps` decorator now adds a :attr:`__wrapped__` attribute * The :func:`functools.wraps` decorator now adds a :attr:`__wrapped__` attribute

View File

@ -574,7 +574,7 @@ class Counter(dict):
# http://en.wikipedia.org/wiki/Multiset # http://en.wikipedia.org/wiki/Multiset
# http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html # 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://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm
# https://github.com/ActiveState/code/tree/master/recipes/Python/259174_bag_collection_class/recipe-259174.py # http://code.activestate.com/recipes/259174/
# Knuth, TAOCP Vol. II section 4.6.3 # Knuth, TAOCP Vol. II section 4.6.3
def __init__(self, iterable=None, /, **kwds): def __init__(self, iterable=None, /, **kwds):

View File

@ -456,7 +456,7 @@ def merge(*iterables, key=None, reverse=False):
# 2) Made multiple passes over the data. # 2) Made multiple passes over the data.
# 3) Made more comparisons in common cases (small k, large n, semi-random input). # 3) Made more comparisons in common cases (small k, large n, semi-random input).
# See the more detailed comparison of approach at: # See the more detailed comparison of approach at:
# https://github.com/ActiveState/code/tree/master/recipes/Python/577573_Compare_algorithms/recipe-577573.py # http://code.activestate.com/recipes/577573-compare-algorithms-for-heapqsmallest
def nsmallest(n, iterable, key=None): def nsmallest(n, iterable, key=None):
"""Find the n smallest elements in a dataset. """Find the n smallest elements in a dataset.

View File

@ -611,7 +611,7 @@ class MathTests(unittest.TestCase):
def msum(iterable): def msum(iterable):
"""Full precision summation. Compute sum(iterable) without any """Full precision summation. Compute sum(iterable) without any
intermediate accumulation of error. Based on the 'lsum' function intermediate accumulation of error. Based on the 'lsum' function
at https://github.com/ActiveState/code/tree/master/recipes/Python/393090_Binary_floating_point_summatiaccurate_full/recipe-393090.py at http://code.activestate.com/recipes/393090/
""" """
tmant, texp = 0, 0 tmant, texp = 0, 0

View File

@ -18,7 +18,7 @@ def strongly_connected_components(
exactly once; vertices not part of a SCC are returned as exactly once; vertices not part of a SCC are returned as
singleton sets. singleton sets.
From https://github.com/ActiveState/code/tree/master/recipes/Python/578507_Strongly_connected_components_directed/recipe-578507.py. From http://code.activestate.com/recipes/578507/.
""" """
identified: Set[str] = set() identified: Set[str] = set()
stack: List[str] = [] stack: List[str] = []
@ -81,7 +81,7 @@ def topsort(
{B, C} {B, C}
{A} {A}
From https://github.com/ActiveState/code/tree/master/recipes/Python/577413_Topological_Sort/recipe-577413.py. From http://code.activestate.com/recipes/577413/.
""" """
# TODO: Use a faster algorithm? # TODO: Use a faster algorithm?
for k, v in data.items(): for k, v in data.items():