Skip to content

Commit c2445ee

Browse files
committed
Deploying to gh-pages from @ 860ec19 🚀
1 parent 808de40 commit c2445ee

File tree

530 files changed

+740
-768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

530 files changed

+740
-768
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 47b693bb5cf37a4993f0ad3e8f17929d
3+
config: 4456476df0dbddf14fc886dd81ffe030
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_sources/glossary.rst.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,11 @@ Glossary
840840
Some named tuples are built-in types (such as the above examples).
841841
Alternatively, a named tuple can be created from a regular class
842842
definition that inherits from :class:`tuple` and that defines named
843-
fields. Such a class can be written by hand or it can be created with
844-
the factory function :func:`collections.namedtuple`. The latter
845-
technique also adds some extra methods that may not be found in
846-
hand-written or built-in named tuples.
843+
fields. Such a class can be written by hand, or it can be created by
844+
inheriting :class:`typing.NamedTuple`, or with the factory function
845+
:func:`collections.namedtuple`. The latter techniques also add some
846+
extra methods that may not be found in hand-written or built-in named
847+
tuples.
847848

848849
namespace
849850
The place where a variable is stored. Namespaces are implemented as

_sources/library/itertools.rst.txt

Lines changed: 103 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ The following recipes have a more mathematical flavor:
990990

991991
def sum_of_squares(it):
992992
"Add up the squares of the input values."
993-
# sum_of_squares([10, 20, 30]) -> 1400
993+
# sum_of_squares([10, 20, 30]) --> 1400
994994
return math.sumprod(*tee(it))
995995
996996
def reshape(matrix, cols):
@@ -1011,17 +1011,16 @@ The following recipes have a more mathematical flavor:
10111011

10121012
def convolve(signal, kernel):
10131013
"""Discrete linear convolution of two iterables.
1014+
Equivalent to polynomial multiplication.
10141015

1015-
The kernel is fully consumed before the calculations begin.
1016-
The signal is consumed lazily and can be infinite.
1017-
1018-
Convolutions are mathematically commutative.
1019-
If the signal and kernel are swapped,
1020-
the output will be the same.
1016+
Convolutions are mathematically commutative; however, the inputs are
1017+
evaluated differently. The signal is consumed lazily and can be
1018+
infinite. The kernel is fully consumed before the calculations begin.
10211019

10221020
Article: https://betterexplained.com/articles/intuitive-convolution/
10231021
Video: https://www.youtube.com/watch?v=KuXjwB4LzSA
10241022
"""
1023+
# convolve([1, -1, -20], [1, -3]) --> 1 -4 -17 60
10251024
# convolve(data, [0.25, 0.25, 0.25, 0.25]) --> Moving average (blur)
10261025
# convolve(data, [1/2, 0, -1/2]) --> 1st derivative estimate
10271026
# convolve(data, [1, -2, 1]) --> 2nd derivative estimate
@@ -1059,7 +1058,7 @@ The following recipes have a more mathematical flavor:
10591058
f(x) = x³ -4x² -17x + 60
10601059
f'(x) = 3x² -8x -17
10611060
"""
1062-
# polynomial_derivative([1, -4, -17, 60]) -> [3, -8, -17]
1061+
# polynomial_derivative([1, -4, -17, 60]) --> [3, -8, -17]
10631062
n = len(coefficients)
10641063
powers = reversed(range(1, n))
10651064
return list(map(operator.mul, coefficients, powers))
@@ -1161,6 +1160,12 @@ The following recipes have a more mathematical flavor:
11611160

11621161
>>> take(10, count())
11631162
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
1163+
>>> # Verify that the input is consumed lazily
1164+
>>> it = iter('abcdef')
1165+
>>> take(3, it)
1166+
['a', 'b', 'c']
1167+
>>> list(it)
1168+
['d', 'e', 'f']
11641169

11651170
>>> list(prepend(1, [2, 3, 4]))
11661171
[1, 2, 3, 4]
@@ -1173,25 +1178,45 @@ The following recipes have a more mathematical flavor:
11731178

11741179
>>> list(tail(3, 'ABCDEFG'))
11751180
['E', 'F', 'G']
1181+
>>> # Verify the input is consumed greedily
1182+
>>> input_iterator = iter('ABCDEFG')
1183+
>>> output_iterator = tail(3, input_iterator)
1184+
>>> list(input_iterator)
1185+
[]
11761186

11771187
>>> it = iter(range(10))
11781188
>>> consume(it, 3)
1189+
>>> # Verify the input is consumed lazily
11791190
>>> next(it)
11801191
3
1192+
>>> # Verify the input is consumed completely
11811193
>>> consume(it)
11821194
>>> next(it, 'Done')
11831195
'Done'
11841196

11851197
>>> nth('abcde', 3)
11861198
'd'
1187-
11881199
>>> nth('abcde', 9) is None
11891200
True
1201+
>>> # Verify that the input is consumed lazily
1202+
>>> it = iter('abcde')
1203+
>>> nth(it, 2)
1204+
'c'
1205+
>>> list(it)
1206+
['d', 'e']
11901207

11911208
>>> [all_equal(s) for s in ('', 'A', 'AAAA', 'AAAB', 'AAABA')]
11921209
[True, True, True, False, False]
11931210
>>> [all_equal(s, key=str.casefold) for s in ('', 'A', 'AaAa', 'AAAB', 'AAABA')]
11941211
[True, True, True, False, False]
1212+
>>> # Verify that the input is consumed lazily and that only
1213+
>>> # one element of a second equivalence class is used to disprove
1214+
>>> # the assertion that all elements are equal.
1215+
>>> it = iter('aaabbbccc')
1216+
>>> all_equal(it)
1217+
False
1218+
>>> ''.join(it)
1219+
'bbccc'
11951220

11961221
>>> quantify(range(99), lambda x: x%2==0)
11971222
50
@@ -1214,6 +1239,11 @@ The following recipes have a more mathematical flavor:
12141239

12151240
>>> list(ncycles('abc', 3))
12161241
['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']
1242+
>>> # Verify greedy consumption of input iterator
1243+
>>> input_iterator = iter('abc')
1244+
>>> output_iterator = ncycles(input_iterator, 3)
1245+
>>> list(input_iterator)
1246+
[]
12171247

12181248
>>> sum_of_squares([10, 20, 30])
12191249
1400
@@ -1236,19 +1266,41 @@ The following recipes have a more mathematical flavor:
12361266

12371267
>>> list(transpose([(1, 2, 3), (11, 22, 33)]))
12381268
[(1, 11), (2, 22), (3, 33)]
1269+
>>> # Verify that the inputs are consumed lazily
1270+
>>> input1 = iter([1, 2, 3])
1271+
>>> input2 = iter([11, 22, 33])
1272+
>>> output_iterator = transpose([input1, input2])
1273+
>>> next(output_iterator)
1274+
(1, 11)
1275+
>>> list(zip(input1, input2))
1276+
[(2, 22), (3, 33)]
12391277

12401278
>>> list(matmul([(7, 5), (3, 5)], [[2, 5], [7, 9]]))
12411279
[(49, 80), (41, 60)]
12421280
>>> list(matmul([[2, 5], [7, 9], [3, 4]], [[7, 11, 5, 4, 9], [3, 5, 2, 6, 3]]))
12431281
[(29, 47, 20, 38, 33), (76, 122, 53, 82, 90), (33, 53, 23, 36, 39)]
12441282

1283+
>>> list(convolve([1, -1, -20], [1, -3])) == [1, -4, -17, 60]
1284+
True
12451285
>>> data = [20, 40, 24, 32, 20, 28, 16]
12461286
>>> list(convolve(data, [0.25, 0.25, 0.25, 0.25]))
12471287
[5.0, 15.0, 21.0, 29.0, 29.0, 26.0, 24.0, 16.0, 11.0, 4.0]
12481288
>>> list(convolve(data, [1, -1]))
12491289
[20, 20, -16, 8, -12, 8, -12, -16]
12501290
>>> list(convolve(data, [1, -2, 1]))
12511291
[20, 0, -36, 24, -20, 20, -20, -4, 16]
1292+
>>> # Verify signal is consumed lazily and the kernel greedily
1293+
>>> signal_iterator = iter([10, 20, 30, 40, 50])
1294+
>>> kernel_iterator = iter([1, 2, 3])
1295+
>>> output_iterator = convolve(signal_iterator, kernel_iterator)
1296+
>>> list(kernel_iterator)
1297+
[]
1298+
>>> next(output_iterator)
1299+
10
1300+
>>> next(output_iterator)
1301+
40
1302+
>>> list(signal_iterator)
1303+
[30, 40, 50]
12521304

12531305
>>> from fractions import Fraction
12541306
>>> from decimal import Decimal
@@ -1336,6 +1388,17 @@ The following recipes have a more mathematical flavor:
13361388
>>> # Test list input. Lists do not support None for the stop argument
13371389
>>> list(iter_index(list('AABCADEAF'), 'A'))
13381390
[0, 1, 4, 7]
1391+
>>> # Verify that input is consumed lazily
1392+
>>> input_iterator = iter('AABCADEAF')
1393+
>>> output_iterator = iter_index(input_iterator, 'A')
1394+
>>> next(output_iterator)
1395+
0
1396+
>>> next(output_iterator)
1397+
1
1398+
>>> next(output_iterator)
1399+
4
1400+
>>> ''.join(input_iterator)
1401+
'DEAF'
13391402

13401403
>>> list(sieve(30))
13411404
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
@@ -1487,6 +1550,17 @@ The following recipes have a more mathematical flavor:
14871550
[0, 2, 4, 6, 8]
14881551
>>> list(odds)
14891552
[1, 3, 5, 7, 9]
1553+
>>> # Verify that the input is consumed lazily
1554+
>>> input_iterator = iter(range(10))
1555+
>>> evens, odds = partition(is_odd, input_iterator)
1556+
>>> next(odds)
1557+
1
1558+
>>> next(odds)
1559+
3
1560+
>>> next(evens)
1561+
0
1562+
>>> list(input_iterator)
1563+
[4, 5, 6, 7, 8, 9]
14901564

14911565
>>> list(subslices('ABCD'))
14921566
['A', 'AB', 'ABC', 'ABCD', 'B', 'BC', 'BCD', 'C', 'CD', 'D']
@@ -1506,13 +1580,27 @@ The following recipes have a more mathematical flavor:
15061580
['A', 'B', 'C', 'D']
15071581
>>> list(unique_everseen('ABBcCAD', str.casefold))
15081582
['A', 'B', 'c', 'D']
1583+
>>> # Verify that the input is consumed lazily
1584+
>>> input_iterator = iter('AAAABBBCCDAABBB')
1585+
>>> output_iterator = unique_everseen(input_iterator)
1586+
>>> next(output_iterator)
1587+
'A'
1588+
>>> ''.join(input_iterator)
1589+
'AAABBBCCDAABBB'
15091590

15101591
>>> list(unique_justseen('AAAABBBCCDAABBB'))
15111592
['A', 'B', 'C', 'D', 'A', 'B']
15121593
>>> list(unique_justseen('ABBCcAD', str.casefold))
15131594
['A', 'B', 'C', 'A', 'D']
15141595
>>> list(unique_justseen('ABBcCAD', str.casefold))
15151596
['A', 'B', 'c', 'A', 'D']
1597+
>>> # Verify that the input is consumed lazily
1598+
>>> input_iterator = iter('AAAABBBCCDAABBB')
1599+
>>> output_iterator = unique_justseen(input_iterator)
1600+
>>> next(output_iterator)
1601+
'A'
1602+
>>> ''.join(input_iterator)
1603+
'AAABBBCCDAABBB'
15161604

15171605
>>> d = dict(a=1, b=2, c=3)
15181606
>>> it = iter_except(d.popitem, KeyError)
@@ -1533,6 +1621,12 @@ The following recipes have a more mathematical flavor:
15331621

15341622
>>> first_true('ABC0DEF1', '9', str.isdigit)
15351623
'0'
1624+
>>> # Verify that inputs are consumed lazily
1625+
>>> it = iter('ABC0DEF1')
1626+
>>> first_true(it, predicate=str.isdigit)
1627+
'0'
1628+
>>> ''.join(it)
1629+
'DEF1'
15361630

15371631

15381632
.. testcode::

_sources/tutorial/errors.rst.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ complaint you get while you are still learning Python::
2020
>>> while True print('Hello world')
2121
File "<stdin>", line 1
2222
while True print('Hello world')
23-
^
23+
^^^^^
2424
SyntaxError: invalid syntax
2525

26-
The parser repeats the offending line and displays a little 'arrow' pointing at
27-
the earliest point in the line where the error was detected. The error is
28-
caused by (or at least detected at) the token *preceding* the arrow: in the
26+
The parser repeats the offending line and displays little 'arrow's pointing
27+
at the token in the line where the error was detected. The error may be
28+
caused by the absence of a token *before* the indicated token. In the
2929
example, the error is detected at the function :func:`print`, since a colon
3030
(``':'``) is missing before it. File name and line number are printed so you
3131
know where to look in case the input came from a script.

_static/glossary.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ <h3>瀏覽</h3>
309309
<br />
310310
<br />
311311

312-
最後更新於 Mar 10, 2024 (09:05 UTC)。
312+
最後更新於 Mar 13, 2024 (02:41 UTC)。
313313
<a href="/bugs.html">Found a bug</a>?
314314
<br />
315315

bugs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ <h2>說明文件的錯誤<a class="headerlink" href="#documentation-bugs" title=
224224
</section>
225225
<section id="getting-started-contributing-to-python-yourself">
226226
<span id="contributing-to-python"></span><h2>開始讓自己貢獻 Python<a class="headerlink" href="#getting-started-contributing-to-python-yourself" title="Link to this heading"></a></h2>
227-
<p>除了只是回報您所發現的錯誤之外,同樣也歡迎您提交修正它們的修補程式 (patch)。您可以在 <a class="reference external" href="https://devguide.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果您有任何問題,<a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">核心導師郵寄清單</a>是一個友善的地方,您可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
227+
<p>除了只是回報您所發現的錯誤之外,同樣也歡迎您提交修正它們的修補程式 (patch)。您可以在 <a class="reference external" href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果您有任何問題,<a class="reference external" href="https://devguide.python.org/">核心導師郵寄清單</a>是一個友善的地方,您可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
228228
</section>
229229
</section>
230230

@@ -345,7 +345,7 @@ <h3>瀏覽</h3>
345345
<br />
346346
<br />
347347

348-
最後更新於 Mar 10, 2024 (09:05 UTC)。
348+
最後更新於 Mar 13, 2024 (02:41 UTC)。
349349
<a href="/bugs.html">Found a bug</a>?
350350
<br />
351351

c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ <h3>瀏覽</h3>
319319
<br />
320320
<br />
321321

322-
最後更新於 Mar 10, 2024 (09:05 UTC)。
322+
最後更新於 Mar 13, 2024 (02:41 UTC)。
323323
<a href="/bugs.html">Found a bug</a>?
324324
<br />
325325

c-api/allocation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ <h3>瀏覽</h3>
333333
<br />
334334
<br />
335335

336-
最後更新於 Mar 10, 2024 (09:05 UTC)。
336+
最後更新於 Mar 13, 2024 (02:41 UTC)。
337337
<a href="/bugs.html">Found a bug</a>?
338338
<br />
339339

c-api/apiabiversion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ <h3>瀏覽</h3>
365365
<br />
366366
<br />
367367

368-
最後更新於 Mar 10, 2024 (09:05 UTC)。
368+
最後更新於 Mar 13, 2024 (02:41 UTC)。
369369
<a href="/bugs.html">Found a bug</a>?
370370
<br />
371371

0 commit comments

Comments
 (0)