Skip to content

Commit a0e4ea7

Browse files
Deploy preview for PR 1226 🛫
1 parent c3133a3 commit a0e4ea7

582 files changed

Lines changed: 6005 additions & 5968 deletions

File tree

Some content is hidden

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

pr-preview/pr-1226/_sources/library/ast.rst.txt

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,25 @@ Root nodes
274274
Literals
275275
^^^^^^^^
276276

277-
.. class:: Constant(value)
277+
.. class:: Constant(value, kind)
278278

279279
A constant value. The ``value`` attribute of the ``Constant`` literal contains the
280280
Python object it represents. The values represented can be instances of :class:`str`,
281281
:class:`bytes`, :class:`int`, :class:`float`, :class:`complex`, and :class:`bool`,
282282
and the constants :data:`None` and :data:`Ellipsis`.
283283

284+
The ``kind`` attribute is an optional string. For string literals with a
285+
``u`` prefix, ``kind`` is set to ``'u'``. For all other
286+
constants, ``kind`` is ``None``.
287+
284288
.. doctest::
285289

286290
>>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))
287291
Expression(
288292
body=Constant(value=123))
293+
>>> print(ast.dump(ast.parse("u'hello'", mode='eval'), indent=4))
294+
Expression(
295+
body=Constant(value='hello', kind='u'))
289296

290297

291298
.. class:: FormattedValue(value, conversion, format_spec)
@@ -2549,6 +2556,20 @@ and classes for traversing abstract syntax trees:
25492556
type_ignores=[])
25502557

25512558

2559+
.. function:: compare(a, b, /, *, compare_attributes=False)
2560+
2561+
Recursively compares two ASTs.
2562+
2563+
*compare_attributes* affects whether AST attributes are considered
2564+
in the comparison. If *compare_attributes* is ``False`` (default), then
2565+
attributes are ignored. Otherwise they must all be equal. This
2566+
option is useful to check whether the ASTs are structurally equal but
2567+
differ in whitespace or similar details. Attributes include line numbers
2568+
and column offsets.
2569+
2570+
.. versionadded:: 3.14
2571+
2572+
25522573
.. _ast-compiler-flags:
25532574

25542575
Compiler flags
@@ -2584,20 +2605,6 @@ effects on the compilation of a program:
25842605
.. versionadded:: 3.8
25852606

25862607

2587-
.. function:: compare(a, b, /, *, compare_attributes=False)
2588-
2589-
Recursively compares two ASTs.
2590-
2591-
*compare_attributes* affects whether AST attributes are considered
2592-
in the comparison. If *compare_attributes* is ``False`` (default), then
2593-
attributes are ignored. Otherwise they must all be equal. This
2594-
option is useful to check whether the ASTs are structurally equal but
2595-
differ in whitespace or similar details. Attributes include line numbers
2596-
and column offsets.
2597-
2598-
.. versionadded:: 3.14
2599-
2600-
26012608
.. _ast-cli:
26022609

26032610
Command-line usage

pr-preview/pr-1226/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ <h3>導航</h3>
356356
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
357357
<br>
358358
<br>
359-
最後更新於 5月 02, 2026 (00:39 UTC)。
359+
最後更新於 5月 04, 2026 (00:38 UTC)。
360360

361361
<a href="/bugs.html">發現 bug</a>
362362

pr-preview/pr-1226/bugs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ <h3>導航</h3>
393393
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
394394
<br>
395395
<br>
396-
最後更新於 5月 02, 2026 (00:39 UTC)。
396+
最後更新於 5月 04, 2026 (00:38 UTC)。
397397

398398
<a href="/bugs.html">發現 bug</a>
399399

pr-preview/pr-1226/c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ <h3>導航</h3>
365365
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
366366
<br>
367367
<br>
368-
最後更新於 5月 02, 2026 (00:39 UTC)。
368+
最後更新於 5月 04, 2026 (00:38 UTC)。
369369

370370
<a href="/bugs.html">發現 bug</a>
371371

pr-preview/pr-1226/c-api/allocation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ <h3>導航</h3>
577577
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
578578
<br>
579579
<br>
580-
最後更新於 5月 02, 2026 (00:39 UTC)。
580+
最後更新於 5月 04, 2026 (00:38 UTC)。
581581

582582
<a href="/bugs.html">發現 bug</a>
583583

pr-preview/pr-1226/c-api/apiabiversion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ <h3>導航</h3>
514514
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
515515
<br>
516516
<br>
517-
最後更新於 5月 02, 2026 (00:39 UTC)。
517+
最後更新於 5月 04, 2026 (00:38 UTC)。
518518

519519
<a href="/bugs.html">發現 bug</a>
520520

pr-preview/pr-1226/c-api/arg.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ <h3>導航</h3>
996996
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
997997
<br>
998998
<br>
999-
最後更新於 5月 02, 2026 (00:39 UTC)。
999+
最後更新於 5月 04, 2026 (00:38 UTC)。
10001000

10011001
<a href="/bugs.html">發現 bug</a>
10021002

pr-preview/pr-1226/c-api/bool.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ <h3>導航</h3>
376376
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
377377
<br>
378378
<br>
379-
最後更新於 5月 02, 2026 (00:39 UTC)。
379+
最後更新於 5月 04, 2026 (00:38 UTC)。
380380

381381
<a href="/bugs.html">發現 bug</a>
382382

pr-preview/pr-1226/c-api/buffer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ <h3>導航</h3>
10641064
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
10651065
<br>
10661066
<br>
1067-
最後更新於 5月 02, 2026 (00:39 UTC)。
1067+
最後更新於 5月 04, 2026 (00:38 UTC)。
10681068

10691069
<a href="/bugs.html">發現 bug</a>
10701070

pr-preview/pr-1226/c-api/bytearray.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ <h3>導航</h3>
457457
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
458458
<br>
459459
<br>
460-
最後更新於 5月 02, 2026 (00:39 UTC)。
460+
最後更新於 5月 04, 2026 (00:38 UTC)。
461461

462462
<a href="/bugs.html">發現 bug</a>
463463

0 commit comments

Comments
 (0)