File tree 3 files changed +31
-0
lines changed
3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1807,6 +1807,7 @@ returns a boolean value regardless of the type of its argument
1807
1807
single: assignment expression
1808
1808
single: walrus operator
1809
1809
single: named expression
1810
+ pair: assignment; expression
1810
1811
1811
1812
Assignment expressions
1812
1813
======================
Original file line number Diff line number Diff line change @@ -1870,6 +1870,7 @@ class Helper:
1870
1870
':' : 'SLICINGS DICTIONARYLITERALS' ,
1871
1871
'@' : 'def class' ,
1872
1872
'\\ ' : 'STRINGS' ,
1873
+ ':=' : 'ASSIGNMENTEXPRESSIONS' ,
1873
1874
'_' : 'PRIVATENAMES' ,
1874
1875
'__' : 'PRIVATENAMES SPECIALMETHODS' ,
1875
1876
'`' : 'BACKQUOTES' ,
@@ -1963,6 +1964,7 @@ class Helper:
1963
1964
'ASSERTION' : 'assert' ,
1964
1965
'ASSIGNMENT' : ('assignment' , 'AUGMENTEDASSIGNMENT' ),
1965
1966
'AUGMENTEDASSIGNMENT' : ('augassign' , 'NUMBERMETHODS' ),
1967
+ 'ASSIGNMENTEXPRESSIONS' : ('assignment-expressions' , '' ),
1966
1968
'DELETION' : 'del' ,
1967
1969
'RETURNING' : 'return' ,
1968
1970
'IMPORTING' : 'import' ,
Original file line number Diff line number Diff line change 416
416
'some expressions (like un-parenthesized tuple expressions) '
417
417
'caused a\n'
418
418
'syntax error.\n',
419
+ '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',
419
447
'async': 'Coroutines\n'
420
448
'**********\n'
421
449
'\n'
You can’t perform that action at this time.
0 commit comments