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

Commit447a151

Browse files
gh-125072: Add label for assignment expressions; update tracked section for assignment expression topic (#125074)
1 parenta7f0727 commit447a151

File tree

3 files changed

+41
-29
lines changed

3 files changed

+41
-29
lines changed

‎Doc/reference/expressions.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,8 @@ returns a boolean value regardless of the type of its argument
18091809
single: named expression
18101810
pair: assignment; expression
18111811

1812+
.. _assignment-expressions:
1813+
18121814
Assignment expressions
18131815
======================
18141816

‎Doc/tools/extensions/pyspecific.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ def run(self):
353353
# Support for building "topic help" for pydoc
354354

355355
pydoc_topic_labels= [
356-
'assert','assignment','async','atom-identifiers','atom-literals',
357-
'attribute-access','attribute-references','augassign','await',
356+
'assert','assignment','assignment-expressions','async','atom-identifiers',
357+
'atom-literals','attribute-access','attribute-references','augassign','await',
358358
'binary','bitwise','bltin-code-objects','bltin-ellipsis-object',
359359
'bltin-null-object','bltin-type-objects','booleans',
360360
'break','callable-types','calls','class','comparisons','compound',

‎Lib/pydoc_data/topics.py‎

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -417,33 +417,43 @@
417417
'caused a\n'
418418
'syntax error.\n',
419419
'assignment-expressions': 'Assignment expressions\n'
420-
'**********************\n'
421-
'\n'
422-
'An assignment expression (sometimes also called a “named expression”'
423-
'\nor “walrus”) assigns an expression to an identifier, while also\n'
424-
'returning the value of the expression.\n'
425-
'\n'
426-
'One common use case is when handling matched regular expressions:\n'
427-
'\n'
428-
' if matching := pattern.search(data):\n'
429-
' do_something(matching)\n'
430-
'\n'
431-
'Or, when processing a file stream in chunks:\n'
432-
'\n'
433-
' while chunk := file.read(9000):\n'
434-
' process(chunk)\n'
435-
'\n'
436-
'Assignment expressions must be surrounded by parentheses when used as\n'
437-
'expression statements and when used as sub-expressions in slicing,\n'
438-
'conditional, lambda, keyword-argument, and comprehension-if\n'
439-
'expressions and in assert, with, and assignment statements. In all\n'
440-
'other places where they can be used, parentheses are not required,\n'
441-
'including in if and while statements.\n'
442-
'\n'
443-
'Added in version 3.8.\n'
444-
'See also:\n'
445-
'\n'
446-
' **PEP 572** - Assignment Expressions\n',
420+
'**********************\n'
421+
'\n'
422+
' assignment_expression ::= [identifier ":="] '
423+
'expression\n'
424+
'\n'
425+
'An assignment expression (sometimes also called a '
426+
'“named expression”\n'
427+
'or “walrus”) assigns an "expression" to an '
428+
'"identifier", while also\n'
429+
'returning the value of the "expression".\n'
430+
'\n'
431+
'One common use case is when handling matched '
432+
'regular expressions:\n'
433+
'\n'
434+
' if matching := pattern.search(data):\n'
435+
' do_something(matching)\n'
436+
'\n'
437+
'Or, when processing a file stream in chunks:\n'
438+
'\n'
439+
' while chunk := file.read(9000):\n'
440+
' process(chunk)\n'
441+
'\n'
442+
'Assignment expressions must be surrounded by '
443+
'parentheses when used as\n'
444+
'expression statements and when used as '
445+
'sub-expressions in slicing,\n'
446+
'conditional, lambda, keyword-argument, and '
447+
'comprehension-if\n'
448+
'expressions and in "assert", "with", and '
449+
'"assignment" statements. In\n'
450+
'all other places where they can be used, '
451+
'parentheses are not required,\n'
452+
'including in "if" and "while" statements.\n'
453+
'\n'
454+
'Added in version 3.8: See **PEP 572** for more '
455+
'details about\n'
456+
'assignment expressions.\n',
447457
'async': 'Coroutines\n'
448458
'**********\n'
449459
'\n'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp