Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d612b5

Browse files
Deploy preview for PR 1148 🛫
1 parent830e9ec commit8d612b5

File tree

577 files changed

+811
-675
lines changed

Some content is hidden

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

577 files changed

+811
-675
lines changed

‎pr-preview/pr-1148/_sources/howto/a-conceptual-overview-of-asyncio.rst.txt‎

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ model of how :mod:`asyncio` fundamentally works, helping you understand the
99
how and why behind the recommended patterns.
1010

1111
You might be curious about some key:mod:`!asyncio` concepts.
12-
You'll be comfortably able to answer these questions by the end of this
13-
article:
12+
By the end of this article, you'll be able to comfortably answer these questions:
1413

1514
- What's happening behind the scenes when an object is awaited?
1615
- How does:mod:`!asyncio` differentiate between a task which doesn't need
17-
CPU-time (such as a network request or file read) as opposed to a task that
16+
CPUtime (such as a network request or file read) as opposed to a task that
1817
does (such as computing n-factorial)?
1918
- How to write an asynchronous variant of an operation, such as
2019
an async sleep or database request.
@@ -35,7 +34,7 @@ A conceptual overview part 1: the high-level
3534
--------------------------------------------
3635

3736
In part 1, we'll cover the main, high-level building blocks of:mod:`!asyncio`:
38-
the event loop, coroutine functions, coroutine objects, tasks and ``await``.
37+
the event loop, coroutine functions, coroutine objects, tasks, and ``await``.
3938

4039
==========
4140
Event Loop
@@ -56,7 +55,7 @@ Once it pauses or completes, it returns control to the event loop.
5655
The event loop will then select another job from its pool and invoke it.
5756
You can *roughly* think of the collection of jobs as a queue: jobs are added and
5857
then processed one at a time, generally (but not always) in order.
59-
This process repeats indefinitely with the event loop cycling endlessly
58+
This process repeats indefinitely, with the event loop cycling endlessly
6059
onwards.
6160
If there are no more jobs pending execution, the event loop is smart enough to
6261
rest and avoid needlessly wasting CPU cycles, and will come back when there's
@@ -276,7 +275,7 @@ in this case, a call to resume ``plant_a_tree()``.
276275

277276
Generally speaking, when the awaited task finishes (``dig_the_hole_task``),
278277
the original task or coroutine (``plant_a_tree()``) is added back to the event
279-
loops to-do list to be resumed.
278+
loop's to-do list to be resumed.
280279

281280
This is a basic, yet reliable mental model.
282281
In practice, the control handoffs are slightly more complex, but not by much.
@@ -310,7 +309,7 @@ Consider this program::
310309
The first statement in the coroutine ``main()`` creates ``task_b`` and schedules
311310
it for execution via the event loop.
312311
Then, ``coro_a()`` is repeatedly awaited. Control never cedes to the
313-
event loop which is why we see the output of all three ``coro_a()``
312+
event loop, which is why we see the output of all three ``coro_a()``
314313
invocations before ``coro_b()``'s output:
315314

316315
..code-block::none
@@ -338,8 +337,8 @@ This behavior of ``await coroutine`` can trip a lot of people up!
338337
That example highlights how using only ``await coroutine`` could
339338
unintentionally hog control from other tasks and effectively stall the event
340339
loop.
341-
:func:`asyncio.run` can help you detect suchoccurences via the
342-
``debug=True`` flag which accordingly enables
340+
:func:`asyncio.run` can help you detect suchoccurrences via the
341+
``debug=True`` flag, which enables
343342
:ref:`debug mode<asyncio-debug-mode>`.
344343
Among other things, it will log any coroutines that monopolize execution for
345344
100ms or longer.
@@ -348,8 +347,8 @@ The design intentionally trades off some conceptual clarity around usage of
348347
``await`` for improved performance.
349348
Each time a task is awaited, control needs to be passed all the way up the
350349
call stack to the event loop.
351-
That might sound minor, but in a large program with many ``await``'s and a deep
352-
callstack that overhead can add up to a meaningful performance drag.
350+
That might sound minor, but in a large program with many ``await`` statements and a deep
351+
call stack, that overhead can add up to a meaningful performance drag.
353352

354353
------------------------------------------------
355354
A conceptual overview part 2: the nuts and bolts
@@ -372,7 +371,7 @@ resume a coroutine.
372371
If the coroutine was paused and is now being resumed, the argument ``arg``
373372
will be sent in as the return value of the ``yield`` statement which originally
374373
paused it.
375-
If the coroutine is being used for the first time (as opposed to being resumed)
374+
If the coroutine is being used for the first time (as opposed to being resumed),
376375
``arg`` must be ``None``.
377376

378377
..code-block::
@@ -403,14 +402,14 @@ If the coroutine is being used for the first time (as opposed to being resumed)
403402
returned_value = e.value
404403
print(f"Coroutine main() finished and provided value: {returned_value}.")
405404
406-
:ref:`yield<yieldexpr>`,like usual, pauses execution and returns control
405+
:ref:`yield<yieldexpr>`,as usual, pauses execution and returns control
407406
to the caller.
408407
In the example above, the ``yield``, on line 3, is called by
409408
``... = await rock`` on line 11.
410409
More broadly speaking, ``await`` calls the:meth:`~object.__await__` method of
411410
the given object.
412411
``await`` also does one more very special thing: it propagates (or "passes
413-
along") any ``yield``\s it receives up the call-chain.
412+
along") any ``yield``\s it receives up the callchain.
414413
In this case, that's back to ``... = coroutine.send(None)`` on line 16.
415414

416415
The coroutine is resumed via the ``coroutine.send(42)`` call on line 21.
@@ -462,12 +461,12 @@ computation's status and result.
462461
The term is a nod to the idea of something still to come or not yet happened,
463462
and the object is a way to keep an eye on that something.
464463

465-
A future has a few important attributes. One is its state which can be either
466-
"pending", "cancelled" or "done".
464+
A future has a few important attributes. One is its state, which can be either
465+
"pending", "cancelled", or "done".
467466
Another is its result, which is set when the state transitions to done.
468467
Unlike a coroutine, a future does not represent the actual computation to be
469468
done; instead, it represents the status and result of that computation, kind of
470-
like a status light (red, yellow or green) or indicator.
469+
like a status light (red, yellow, or green) or indicator.
471470

472471
:class:`asyncio.Task` subclasses:class:`asyncio.Future` in order to gain
473472
these various capabilities.
@@ -490,8 +489,8 @@ We'll go through an example of how you could leverage a future to create your
490489
own variant of asynchronous sleep (``async_sleep``) which mimics
491490
:func:`asyncio.sleep`.
492491

493-
This snippet registers a few tasks with the event loop and then awaitsa
494-
coroutine wrapped in a task:``async_sleep(3)``.
492+
This snippet registers a few tasks with the event loop and then awaitsthe task
493+
created by ``asyncio.create_task``, which wraps the``async_sleep(3)`` coroutine.
495494
We want that task to finish only after three seconds have elapsed, but without
496495
preventing other tasks from running.
497496

@@ -540,8 +539,8 @@ will monitor how much time has elapsed and, accordingly, call
540539
# Block until the future is marked as done.
541540
await future
542541

543-
Below, we'll use a rather bareobject,``YieldToEventLoop()``, to ``yield``
544-
from ``__await__``in order to cede control to the event loop.
542+
Below, we use a rather bare ``YieldToEventLoop()`` object to ``yield``
543+
fromits``__await__``method, ceding control to the event loop.
545544
This is effectively the same as calling ``asyncio.sleep(0)``, but this approach
546545
offers more clarity, not to mention it's somewhat cheating to use
547546
``asyncio.sleep`` when showcasing how to implement it!
@@ -552,13 +551,13 @@ The ``watcher_task``, which runs the coroutine ``_sleep_watcher(...)``, will
552551
be invoked once per full cycle of the event loop.
553552
On each resumption, it'll check the time and if not enough has elapsed, then
554553
it'll pause once again and hand control back to the event loop.
555-
Eventually, enough timewill haveelapsed,and``_sleep_watcher(...)`` will
556-
mark the future as done, andthen itself finish toobybreaking out of the
554+
Once enough timehaselapsed, ``_sleep_watcher(...)``
555+
marks the future as done andcompletesbyexiting its
557556
infinite ``while`` loop.
558557
Given this helper task is only invoked once per cycle of the event loop,
559558
you'd be correct to note that this asynchronous sleep will sleep *at least*
560559
three seconds, rather than exactly three seconds.
561-
Note this is alsooftrue of ``asyncio.sleep``.
560+
Note this is also true of ``asyncio.sleep``.
562561

563562
::
564563

@@ -601,6 +600,6 @@ For reference, you could implement it without futures, like so::
601600
else:
602601
await YieldToEventLoop()
603602

604-
But, that's all for now. Hopefully you're ready to more confidently dive into
603+
But that's all for now. Hopefully you're ready to more confidently dive into
605604
some async programming or check out advanced topics in the
606605
:mod:`rest of the documentation <asyncio>`.

‎pr-preview/pr-1148/_sources/library/cmath.rst.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ Constants
338338
..data::nan
339339

340340
A floating-point "not a number" (NaN) value. Equivalent to
341-
``float('nan')``.
341+
``float('nan')``. See also:data:`math.nan`.
342342

343343
..versionadded::3.6
344344

‎pr-preview/pr-1148/_sources/library/http.rst.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ equal to the constant name (i.e. ``http.HTTPStatus.OK`` is also available as
139139

140140
..versionchanged::3.13
141141
Implemented RFC9110 naming for status constants. Old constant names are preserved for
142-
backwards compatibility.
142+
backwards compatibility: ``413 REQUEST_ENTITY_TOO_LARGE``, ``414 REQUEST_URI_TOO_LONG``,
143+
``416 REQUESTED_RANGE_NOT_SATISFIABLE`` and ``422 UNPROCESSABLE_ENTITY``.
143144

144145
HTTP status category
145146
--------------------

‎pr-preview/pr-1148/_sources/library/smtplib.rst.txt‎

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
8080

8181
An:class:`SMTP_SSL` instance behaves exactly the same as instances of
8282
:class:`SMTP`.:class:`SMTP_SSL` should be used for situations where SSL is
83-
required from the beginning of the connection and using:meth:`starttls` is
84-
not appropriate. If *host* is not specified, the local host is used. If
83+
required from the beginning of the connection and using:meth:`~SMTP.starttls`
84+
isnot appropriate. If *host* is not specified, the local host is used. If
8585
*port* is zero, the standard SMTP-over-SSL port (465) is used. The optional
8686
arguments *local_hostname*, *timeout* and *source_address* have the same
8787
meaning as they do in the:class:`SMTP` class. *context*, also optional,
@@ -112,7 +112,7 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
112112

113113
The LMTP protocol, which is very similar to ESMTP, is heavily based on the
114114
standard SMTP client. It's common to use Unix sockets for LMTP, so our
115-
:meth:`connect` method must support that as well as a regular host:port
115+
:meth:`~SMTP.connect` method must support that as well as a regular host:port
116116
server. The optional arguments *local_hostname* and *source_address* have the
117117
same meaning as they do in the:class:`SMTP` class. To specify a Unix
118118
socket, you must use an absolute path for *host*, starting with a '/'.
@@ -147,9 +147,15 @@ A nice selection of exceptions is defined as well:
147147
..exception::SMTPResponseException
148148

149149
Base class for all exceptions that include an SMTP error code. These exceptions
150-
are generated in some instances when the SMTP server returns an error code. The
151-
error code is stored in the:attr:`smtp_code` attribute of the error, and the
152-
:attr:`smtp_error` attribute is set to the error message.
150+
are generated in some instances when the SMTP server returns an error code.
151+
152+
..attribute::smtp_code
153+
154+
The error code.
155+
156+
..attribute::smtp_error
157+
158+
The error message.
153159

154160

155161
..exception::SMTPSenderRefused
@@ -161,9 +167,13 @@ A nice selection of exceptions is defined as well:
161167

162168
..exception::SMTPRecipientsRefused
163169

164-
All recipient addresses refused. The errors for each recipient are accessible
165-
through the attribute:attr:`recipients`, which is a dictionary of exactly the
166-
same sort as:meth:`SMTP.sendmail` returns.
170+
All recipient addresses refused.
171+
172+
..attribute::recipients
173+
174+
A dictionary of exactly the same sort as returned
175+
by:meth:`SMTP.sendmail` containing the errors for
176+
each recipient.
167177

168178

169179
..exception::SMTPDataError
@@ -213,7 +223,6 @@ SMTP Objects
213223

214224
An:class:`SMTP` instance has the following methods:
215225

216-
217226
..method::SMTP.set_debuglevel(level)
218227

219228
Set the debug output level. A value of 1 or ``True`` for *level* results in
@@ -417,7 +426,7 @@ An :class:`SMTP` instance has the following methods:
417426

418427
..versionchanged::3.4
419428
The method now supports hostname check with
420-
:attr:`SSLContext.check_hostname` and *Server Name Indicator* (see
429+
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indicator* (see
421430
:const:`~ssl.HAS_SNI`).
422431

423432
..versionchanged::3.5
@@ -435,7 +444,7 @@ An :class:`SMTP` instance has the following methods:
435444
ESMTP options (such as ``DSN`` commands) that should be used with all ``RCPT``
436445
commands can be passed as *rcpt_options*. (If you need to use different ESMTP
437446
options to different recipients you have to use the low-level methods such as
438-
:meth:`mail`,:meth:`rcpt` and:meth:`data` to send the message.)
447+
:meth:`!mail`,:meth:`!rcpt` and:meth:`!data` to send the message.)
439448

440449
..note::
441450

@@ -467,10 +476,7 @@ An :class:`SMTP` instance has the following methods:
467476
This method may raise the following exceptions:
468477

469478
:exc:`SMTPRecipientsRefused`
470-
All recipients were refused. Nobody got the mail. The:attr:`recipients`
471-
attribute of the exception object is a dictionary with information about the
472-
refused recipients (like the one returned when at least one recipient was
473-
accepted).
479+
All recipients were refused. Nobody got the mail.
474480

475481
:exc:`SMTPHeloError`
476482
The server didn't reply properly to the ``HELO`` greeting.
@@ -546,6 +552,30 @@ Low-level methods corresponding to the standard SMTP/ESMTP commands ``HELP``,
546552
Normally these do not need to be called directly, so they are not documented
547553
here. For details, consult the module code.
548554

555+
Additionally, an SMTP instance has the following attributes:
556+
557+
558+
..attribute::SMTP.helo_resp
559+
560+
The response to the ``HELO`` command, see:meth:`helo`.
561+
562+
563+
..attribute::SMTP.ehlo_resp
564+
565+
The response to the ``EHLO`` command, see:meth:`ehlo`.
566+
567+
568+
..attribute::SMTP.does_esmtp
569+
570+
A boolean value indicating whether the server supports ESMTP, see
571+
:meth:`ehlo`.
572+
573+
574+
..attribute::SMTP.esmtp_features
575+
576+
A dictionary of the names of SMTP service extensions supported by the server,
577+
see:meth:`ehlo`.
578+
549579

550580
.. _smtp-example:
551581

‎pr-preview/pr-1148/_sources/library/stdtypes.rst.txt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,6 +2157,19 @@ expression support in the :mod:`re` module).
21572157
character, for example uppercase characters may only follow uncased characters
21582158
and lowercase characters only cased ones. Return ``False`` otherwise.
21592159

2160+
For example:
2161+
2162+
..doctest::
2163+
2164+
>>>'Spam, Spam, Spam'.istitle()
2165+
True
2166+
>>>'spam, spam, spam'.istitle()
2167+
False
2168+
>>>'SPAM, SPAM, SPAM'.istitle()
2169+
False
2170+
2171+
See also:meth:`title`.
2172+
21602173

21612174
..method::str.isupper()
21622175

@@ -2534,6 +2547,8 @@ expression support in the :mod:`re` module).
25342547
>>> titlecase("they're bill's friends.")
25352548
"They're Bill's Friends."
25362549

2550+
See also:meth:`istitle`.
2551+
25372552

25382553
..method::str.translate(table, /)
25392554

‎pr-preview/pr-1148/_sources/library/time.rst.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ Functions
238238

239239
The result has the following attributes:
240240

241-
- *adjustable*: ``True`` if the clock can bechanged automatically (e.g. by
242-
a NTP daemon) or manually by the system administrator, ``False`` otherwise
241+
- *adjustable*: ``True`` if the clock can beset to jump forward or backward
242+
in time, ``False`` otherwise. Does not refer to gradual NTP rate adjustments.
243243
- *implementation*: The name of the underlying C function used to get
244244
the clock value. Refer to:ref:`time-clock-id-constants` for possible values.
245245
- *monotonic*: ``True`` if the clock cannot go backward,

‎pr-preview/pr-1148/_sources/reference/expressions.rst.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,8 +1938,9 @@ Conditional expressions
19381938
conditional_expression: `or_test` ["if" `or_test` "else" `expression`]
19391939
expression: `conditional_expression` | `lambda_expr`
19401940

1941-
Conditional expressions (sometimes called a "ternary operator") have the lowest
1942-
priority of all Python operations.
1941+
A conditional expression (sometimes called a "ternary operator") is an
1942+
alternative to the if-else statement. As it is an expression, it returns a value
1943+
and can appear as a sub-expression.
19431944

19441945
The expression ``x if C else y`` first evaluates the condition, *C* rather than *x*.
19451946
If *C* is true, *x* is evaluated and its value is returned; otherwise, *y* is

‎pr-preview/pr-1148/about.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ <h3>導航</h3>
314314
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
315315
<br>
316316
<br>
317-
最後更新於 10月14, 2025 (00:20 UTC)。
317+
最後更新於 10月15, 2025 (00:24 UTC)。
318318

319319
<ahref="/bugs.html">發現 bug</a>
320320

‎pr-preview/pr-1148/bugs.html‎

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

@@ -352,7 +352,7 @@ <h3>導航</h3>
352352
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
353353
<br>
354354
<br>
355-
最後更新於 10月14, 2025 (00:20 UTC)。
355+
最後更新於 10月15, 2025 (00:24 UTC)。
356356

357357
<ahref="/bugs.html">發現 bug</a>
358358

‎pr-preview/pr-1148/c-api/abstract.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ <h3>導航</h3>
323323
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
324324
<br>
325325
<br>
326-
最後更新於 10月14, 2025 (00:20 UTC)。
326+
最後更新於 10月15, 2025 (00:24 UTC)。
327327

328328
<ahref="/bugs.html">發現 bug</a>
329329

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp