|
417 | 417 | 'caused a\n'
|
418 | 418 | 'syntax error.\n',
|
419 | 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', |
| 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', |
447 | 457 | 'async': 'Coroutines\n'
|
448 | 458 | '**********\n'
|
449 | 459 | '\n'
|
|
0 commit comments