Skip to content

Commit df7a908

Browse files
committed
Deploying to gh-pages from @ c08a2fc 🚀
1 parent 1c51fdd commit df7a908

File tree

538 files changed

+5340
-5326
lines changed

Some content is hidden

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

538 files changed

+5340
-5326
lines changed

_sources/c-api/long.rst.txt

+5
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
538538
Exactly what values are considered compact is an implementation detail
539539
and is subject to change.
540540
541+
.. versionadded:: 3.12
542+
543+
541544
.. c:function:: Py_ssize_t PyUnstable_Long_CompactValue(const PyLongObject* op)
542545
543546
If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`,
544547
return its value.
545548
546549
Otherwise, the return value is undefined.
547550
551+
.. versionadded:: 3.12
552+

_sources/glossary.rst.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ Glossary
585585

586586
As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil`
587587
build configuration. After building Python with this option, code must be
588-
run with :option:`-X gil 0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 <PYTHON_GIL>`
588+
run with :option:`-X gil=0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 <PYTHON_GIL>`
589589
environment variable. This feature enables improved performance for
590590
multi-threaded applications and makes it easier to use multi-core CPUs
591591
efficiently. For more details, see :pep:`703`.

_sources/howto/argparse.rst.txt

+47
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,53 @@ translated messages.
841841

842842
To translate your own strings in the :mod:`argparse` output, use :mod:`gettext`.
843843

844+
Custom type converters
845+
======================
846+
847+
The :mod:`argparse` module allows you to specify custom type converters for
848+
your command-line arguments. This allows you to modify user input before it's
849+
stored in the :class:`argparse.Namespace`. This can be useful when you need to
850+
pre-process the input before it is used in your program.
851+
852+
When using a custom type converter, you can use any callable that takes a
853+
single string argument (the argument value) and returns the converted value.
854+
However, if you need to handle more complex scenarios, you can use a custom
855+
action class with the **action** parameter instead.
856+
857+
For example, let's say you want to handle arguments with different prefixes and
858+
process them accordingly::
859+
860+
import argparse
861+
862+
parser = argparse.ArgumentParser(prefix_chars='-+')
863+
864+
parser.add_argument('-a', metavar='<value>', action='append',
865+
type=lambda x: ('-', x))
866+
parser.add_argument('+a', metavar='<value>', action='append',
867+
type=lambda x: ('+', x))
868+
869+
args = parser.parse_args()
870+
print(args)
871+
872+
Output:
873+
874+
.. code-block:: shell-session
875+
876+
$ python prog.py -a value1 +a value2
877+
Namespace(a=[('-', 'value1'), ('+', 'value2')])
878+
879+
In this example, we:
880+
881+
* Created a parser with custom prefix characters using the ``prefix_chars``
882+
parameter.
883+
884+
* Defined two arguments, ``-a`` and ``+a``, which used the ``type`` parameter to
885+
create custom type converters to store the value in a tuple with the prefix.
886+
887+
Without the custom type converters, the arguments would have treated the ``-a``
888+
and ``+a`` as the same argument, which would have been undesirable. By using custom
889+
type converters, we were able to differentiate between the two arguments.
890+
844891
Conclusion
845892
==========
846893

_sources/library/argparse.rst.txt

+12-1
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ how the command-line arguments should be handled. The supplied actions are:
728728

729729
.. versionadded:: 3.8
730730

731+
Only actions that consume command-line arguments (e.g. ``'store'``,
732+
``'append'`` or ``'extend'``) can be used with positional arguments.
733+
731734
You may also specify an arbitrary action by passing an Action subclass or
732735
other object that implements the same interface. The ``BooleanOptionalAction``
733736
is available in ``argparse`` and adds support for boolean actions such as
@@ -855,6 +858,8 @@ See also :ref:`specifying-ambiguous-arguments`. The supported values are:
855858
If the ``nargs`` keyword argument is not provided, the number of arguments consumed
856859
is determined by the action_. Generally this means a single command-line argument
857860
will be consumed and a single item (not a list) will be produced.
861+
Actions that do not consume command-line arguments (e.g.
862+
``'store_const'``) set ``nargs=0``.
858863

859864

860865
.. _const:
@@ -1780,7 +1785,8 @@ FileType objects
17801785
Argument groups
17811786
^^^^^^^^^^^^^^^
17821787

1783-
.. method:: ArgumentParser.add_argument_group(title=None, description=None)
1788+
.. method:: ArgumentParser.add_argument_group(title=None, description=None, *, \
1789+
[argument_default], [conflict_handler])
17841790

17851791
By default, :class:`ArgumentParser` groups command-line arguments into
17861792
"positional arguments" and "options" when displaying help
@@ -1825,6 +1831,11 @@ Argument groups
18251831

18261832
--bar BAR bar help
18271833

1834+
The optional, keyword-only parameters argument_default_ and conflict_handler_
1835+
allow for finer-grained control of the behavior of the argument group. These
1836+
parameters have the same meaning as in the :class:`ArgumentParser` constructor,
1837+
but apply specifically to the argument group rather than the entire parser.
1838+
18281839
Note that any arguments not in your user-defined groups will end up back
18291840
in the usual "positional arguments" and "optional arguments" sections.
18301841

_sources/library/asyncio-task.rst.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ other coroutines::
158158
# Nothing happens if we just call "nested()".
159159
# A coroutine object is created but not awaited,
160160
# so it *won't run at all*.
161-
nested()
161+
nested() # will raise a "RuntimeWarning".
162162

163163
# Let's do it differently now and await it:
164164
print(await nested()) # will print "42".

_sources/library/datetime.rst.txt

+17-17
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,19 @@ Objects of the :class:`date` type are always naive.
180180

181181
An object of type :class:`.time` or :class:`.datetime` may be aware or naive.
182182

183-
A :class:`.datetime` object *d* is aware if both of the following hold:
183+
A :class:`.datetime` object ``d`` is aware if both of the following hold:
184184

185185
1. ``d.tzinfo`` is not ``None``
186186
2. ``d.tzinfo.utcoffset(d)`` does not return ``None``
187187

188-
Otherwise, *d* is naive.
188+
Otherwise, ``d`` is naive.
189189

190-
A :class:`.time` object *t* is aware if both of the following hold:
190+
A :class:`.time` object ``t`` is aware if both of the following hold:
191191

192192
1. ``t.tzinfo`` is not ``None``
193193
2. ``t.tzinfo.utcoffset(None)`` does not return ``None``.
194194

195-
Otherwise, *t* is naive.
195+
Otherwise, ``t`` is naive.
196196

197197
The distinction between aware and naive doesn't apply to :class:`timedelta`
198198
objects.
@@ -358,8 +358,8 @@ Supported operations:
358358
+--------------------------------+-----------------------------------------------+
359359
| ``q, r = divmod(t1, t2)`` | Computes the quotient and the remainder: |
360360
| | ``q = t1 // t2`` (3) and ``r = t1 % t2``. |
361-
| | q is an integer and r is a :class:`timedelta` |
362-
| | object. |
361+
| | ``q`` is an integer and ``r`` is a |
362+
| | :class:`timedelta` object. |
363363
+--------------------------------+-----------------------------------------------+
364364
| ``+t1`` | Returns a :class:`timedelta` object with the |
365365
| | same value. (2) |
@@ -526,7 +526,7 @@ Other constructors, all class methods:
526526
January 1 of year 1 has ordinal 1.
527527

528528
:exc:`ValueError` is raised unless ``1 <= ordinal <=
529-
date.max.toordinal()``. For any date *d*,
529+
date.max.toordinal()``. For any date ``d``,
530530
``date.fromordinal(d.toordinal()) == d``.
531531

532532

@@ -697,7 +697,7 @@ Instance methods:
697697
.. method:: date.toordinal()
698698

699699
Return the proleptic Gregorian ordinal of the date, where January 1 of year 1
700-
has ordinal 1. For any :class:`date` object *d*,
700+
has ordinal 1. For any :class:`date` object ``d``,
701701
``date.fromordinal(d.toordinal()) == d``.
702702

703703

@@ -749,7 +749,7 @@ Instance methods:
749749

750750
.. method:: date.__str__()
751751

752-
For a date *d*, ``str(d)`` is equivalent to ``d.isoformat()``.
752+
For a date ``d``, ``str(d)`` is equivalent to ``d.isoformat()``.
753753

754754

755755
.. method:: date.ctime()
@@ -1030,7 +1030,7 @@ Other constructors, all class methods:
10301030
is used. If the *date* argument is a :class:`.datetime` object, its time components
10311031
and :attr:`.tzinfo` attributes are ignored.
10321032

1033-
For any :class:`.datetime` object *d*,
1033+
For any :class:`.datetime` object ``d``,
10341034
``d == datetime.combine(d.date(), d.time(), d.tzinfo)``.
10351035

10361036
.. versionchanged:: 3.6
@@ -1237,11 +1237,11 @@ Supported operations:
12371237

12381238
If both are naive, or both are aware and have the same :attr:`~.datetime.tzinfo` attribute,
12391239
the :attr:`~.datetime.tzinfo` attributes are ignored, and the result is a :class:`timedelta`
1240-
object *t* such that ``datetime2 + t == datetime1``. No time zone adjustments
1240+
object ``t`` such that ``datetime2 + t == datetime1``. No time zone adjustments
12411241
are done in this case.
12421242

12431243
If both are aware and have different :attr:`~.datetime.tzinfo` attributes, ``a-b`` acts
1244-
as if *a* and *b* were first converted to naive UTC datetimes. The
1244+
as if ``a`` and ``b`` were first converted to naive UTC datetimes. The
12451245
result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None)
12461246
- b.utcoffset())`` except that the implementation never overflows.
12471247

@@ -1421,11 +1421,11 @@ Instance methods:
14211421

14221422
.. method:: datetime.utctimetuple()
14231423

1424-
If :class:`.datetime` instance *d* is naive, this is the same as
1424+
If :class:`.datetime` instance ``d`` is naive, this is the same as
14251425
``d.timetuple()`` except that :attr:`~.time.struct_time.tm_isdst` is forced to 0 regardless of what
14261426
``d.dst()`` returns. DST is never in effect for a UTC time.
14271427

1428-
If *d* is aware, *d* is normalized to UTC time, by subtracting
1428+
If ``d`` is aware, ``d`` is normalized to UTC time, by subtracting
14291429
``d.utcoffset()``, and a :class:`time.struct_time` for the
14301430
normalized time is returned. :attr:`!tm_isdst` is forced to 0. Note
14311431
that an :exc:`OverflowError` may be raised if ``d.year`` was
@@ -1573,7 +1573,7 @@ Instance methods:
15731573

15741574
.. method:: datetime.__str__()
15751575

1576-
For a :class:`.datetime` instance *d*, ``str(d)`` is equivalent to
1576+
For a :class:`.datetime` instance ``d``, ``str(d)`` is equivalent to
15771577
``d.isoformat(' ')``.
15781578

15791579

@@ -1820,7 +1820,7 @@ Instance attributes (read-only):
18201820
.. versionadded:: 3.6
18211821

18221822
:class:`.time` objects support equality and order comparisons,
1823-
where *a* is considered less than *b* when *a* precedes *b* in time.
1823+
where ``a`` is considered less than ``b`` when ``a`` precedes ``b`` in time.
18241824

18251825
Naive and aware :class:`!time` objects are never equal.
18261826
Order comparison between naive and aware :class:`!time` objects raises
@@ -1951,7 +1951,7 @@ Instance methods:
19511951

19521952
.. method:: time.__str__()
19531953

1954-
For a time *t*, ``str(t)`` is equivalent to ``t.isoformat()``.
1954+
For a time ``t``, ``str(t)`` is equivalent to ``t.isoformat()``.
19551955

19561956

19571957
.. method:: time.strftime(format)

_sources/library/string.rst.txt

+4-6
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,8 @@ The available presentation types for :class:`float` and
509509
| | significant digits. With no precision given, uses a |
510510
| | precision of ``6`` digits after the decimal point for |
511511
| | :class:`float`, and shows all coefficient digits |
512-
| | for :class:`~decimal.Decimal`. If no digits follow the |
513-
| | decimal point, the decimal point is also removed unless |
514-
| | the ``#`` option is used. |
512+
| | for :class:`~decimal.Decimal`. If ``p=0``, the decimal |
513+
| | point is omitted unless the ``#`` option is used. |
515514
+---------+----------------------------------------------------------+
516515
| ``'E'`` | Scientific notation. Same as ``'e'`` except it uses |
517516
| | an upper case 'E' as the separator character. |
@@ -522,9 +521,8 @@ The available presentation types for :class:`float` and
522521
| | precision given, uses a precision of ``6`` digits after |
523522
| | the decimal point for :class:`float`, and uses a |
524523
| | precision large enough to show all coefficient digits |
525-
| | for :class:`~decimal.Decimal`. If no digits follow the |
526-
| | decimal point, the decimal point is also removed unless |
527-
| | the ``#`` option is used. |
524+
| | for :class:`~decimal.Decimal`. If ``p=0``, the decimal |
525+
| | point is omitted unless the ``#`` option is used. |
528526
+---------+----------------------------------------------------------+
529527
| ``'F'`` | Fixed-point notation. Same as ``'f'``, but converts |
530528
| | ``nan`` to ``NAN`` and ``inf`` to ``INF``. |

_sources/reference/lexical_analysis.rst.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,10 @@ UAX-31, with elaboration and changes as defined below; see also :pep:`3131` for
284284
further details.
285285

286286
Within the ASCII range (U+0001..U+007F), the valid characters for identifiers
287-
are the same as in Python 2.x: the uppercase and lowercase letters ``A`` through
287+
include the uppercase and lowercase letters ``A`` through
288288
``Z``, the underscore ``_`` and, except for the first character, the digits
289289
``0`` through ``9``.
290-
291-
Python 3.0 introduces additional characters from outside the ASCII range (see
290+
Python 3.0 introduced additional characters from outside the ASCII range (see
292291
:pep:`3131`). For these characters, the classification uses the version of the
293292
Unicode Character Database as included in the :mod:`unicodedata` module.
294293

_sources/tutorial/appendix.rst.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This one supports color, multiline editing, history browsing, and
2020
paste mode. To disable color, see :ref:`using-on-controlling-color` for
2121
details. Function keys provide some additional functionality.
2222
:kbd:`F1` enters the interactive help browser :mod:`pydoc`.
23-
:kbd:`F2` allows for browsing command-line history without output nor the
23+
:kbd:`F2` allows for browsing command-line history with neither output nor the
2424
:term:`>>>` and :term:`...` prompts. :kbd:`F3` enters "paste mode", which
2525
makes pasting larger blocks of code easier. Press :kbd:`F3` to return to
2626
the regular prompt.

_sources/tutorial/controlflow.rst.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ Defining Functions
461461
We can create a function that writes the Fibonacci series to an arbitrary
462462
boundary::
463463

464-
>>> def fib(n): # write Fibonacci series up to n
465-
... """Print a Fibonacci series up to n."""
464+
>>> def fib(n): # write Fibonacci series less than n
465+
... """Print a Fibonacci series less than n."""
466466
... a, b = 0, 1
467467
... while a < n:
468468
... print(a, end=' ')

_sources/using/configure.rst.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Features and minimum versions required to build CPython:
2929

3030
* Tcl/Tk 8.5.12 for the :mod:`tkinter` module.
3131

32-
* Autoconf 2.71 and aclocal 1.16.4 are required to regenerate the
32+
* Autoconf 2.71 and aclocal 1.16.5 are required to regenerate the
3333
:file:`configure` script.
3434

3535
.. versionchanged:: 3.1
@@ -56,7 +56,7 @@ Features and minimum versions required to build CPython:
5656
Tcl/Tk version 8.5.12 is now required for the :mod:`tkinter` module.
5757

5858
.. versionchanged:: 3.13
59-
Autoconf 2.71, aclocal 1.16.4 and SQLite 3.15.2 are now required.
59+
Autoconf 2.71, aclocal 1.16.5 and SQLite 3.15.2 are now required.
6060

6161
See also :pep:`7` "Style Guide for C Code" and :pep:`11` "CPython platform
6262
support".

_sources/whatsnew/3.13.rst.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2495,9 +2495,9 @@ Build Changes
24952495
* Building CPython now requires a compiler with support for the C11 atomic
24962496
library, GCC built-in atomic functions, or MSVC interlocked intrinsics.
24972497

2498-
* Autoconf 2.71 and aclocal 1.16.4 are now required to regenerate
2498+
* Autoconf 2.71 and aclocal 1.16.5 are now required to regenerate
24992499
the :file:`configure` script.
2500-
(Contributed by Christian Heimes in :gh:`89886`.)
2500+
(Contributed by Christian Heimes in :gh:`89886` and by Victor Stinner in :gh:`112090`.)
25012501

25022502
* SQLite 3.15.2 or newer is required to build
25032503
the :mod:`sqlite3` extension module.

_static/glossary.json

+1-1
Large diffs are not rendered by default.

about.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,13 @@ <h3>瀏覽</h3>
319319
<a href="https://www.python.org/psf/donations/">Please donate.</a>
320320
<br />
321321
<br />
322-
最後更新於 10月 12, 2024 (01:09 UTC)。
322+
最後更新於 10月 18, 2024 (18:37 UTC)。
323323

324324
<a href="/bugs.html">Found a bug</a>?
325325

326326
<br />
327327

328-
使用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.1 建立。
328+
使用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3 建立。
329329
</div>
330330

331331
</body>

bugs.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ <h2>說明文件的錯誤<a class="headerlink" href="#documentation-bugs" title=
230230
</section>
231231
<section id="getting-started-contributing-to-python-yourself">
232232
<span id="contributing-to-python"></span><h2>開始讓自己貢獻 Python<a class="headerlink" href="#getting-started-contributing-to-python-yourself" title="連結到這個標頭"></a></h2>
233-
<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>
233+
<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>
234234
</section>
235235
</section>
236236

@@ -358,13 +358,13 @@ <h3>瀏覽</h3>
358358
<a href="https://www.python.org/psf/donations/">Please donate.</a>
359359
<br />
360360
<br />
361-
最後更新於 10月 12, 2024 (01:09 UTC)。
361+
最後更新於 10月 18, 2024 (18:37 UTC)。
362362

363363
<a href="/bugs.html">Found a bug</a>?
364364

365365
<br />
366366

367-
使用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.1 建立。
367+
使用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3 建立。
368368
</div>
369369

370370
</body>

c-api/abstract.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,13 @@ <h3>瀏覽</h3>
328328
<a href="https://www.python.org/psf/donations/">Please donate.</a>
329329
<br />
330330
<br />
331-
最後更新於 10月 12, 2024 (01:09 UTC)。
331+
最後更新於 10月 18, 2024 (18:37 UTC)。
332332

333333
<a href="/bugs.html">Found a bug</a>?
334334

335335
<br />
336336

337-
使用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.1 建立。
337+
使用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3 建立。
338338
</div>
339339

340340
</body>

0 commit comments

Comments
 (0)