Read PEPs alongside the Language Reference
Core idea
A Python Enhancement Proposal (PEP) records a proposal, rationale or process. Its status and target release matter: a rejected or superseded proposal is not a current contract. PEP 572 explains assignment expressions introduced in 3.8. For the syntax and semantics of a deployed release, check its language reference, then confirm a small example on that runtime.
The expression both binds size and supplies its value to the comparison.
Expected output:
6Verify a grammar restriction
import astfor source in ('(n := 3)', 'n := 3'): try: ast.parse(source, mode='eval') print('accepted') except SyntaxError: print('rejected')Parentheses are required for a standalone assignment expression in this context.
Expected output:
acceptedrejectedCommon mistake
Do not treat every sentence in a historical PEP as a guarantee of the latest release. Check status, subsequent changes and the versioned reference.
Practice
Open PEP 572 and the 3.13 expression reference. Record one rationale and one actual grammar rule, labeling each source.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
PEP and language reference
Check your understanding of pep and language reference.
What is printed?
print((n := 4) * 2, n)What is printed?
import astprint(type(ast.parse('(n := 3)', mode='eval').body).__name__)Which source gives current core semantics for a specified release?
What must be checked before relying on a PEP?