PEP 572

E51179

PEP 572 is the Python proposal that introduced the “walrus operator” (:=) for assignment expressions, allowing assignment within larger expressions.

AI illustration

How this image was made

AI-generated illustration of PEP 572

This AI-generated illustration was produced by black-forest-labs/FLUX.2-dev (1024x1024) from a prompt written by openai/gpt-oss-120b from the entity's label + description.

Prompt

Generate an image of PEP 572 (PEP 572 is the Python proposal that introduced the “walrus operator” (:=) for assignment expressions, allowing assignment within larger expressions.)

All labels observed (4)

How this entity was disambiguated

Statements (48)

Predicate Object
instanceOf Python Enhancement Proposal ⓘ
affectsComponent Python compiler ⓘ
Python language syntax ⓘ
author Chris Angelico ⓘ
bdfDelegate Guido van Rossum ⓘ
category Python syntax change ⓘ
controversy contributed to Guido van Rossum stepping down as BDFL ⓘ
sparked debate in the Python community about readability ⓘ
created 2018-02-25 ⓘ
decisionProcess BDFL-delegate model ⓘ
definesSyntax NAME ":=" expression ⓘ
designGoal avoid ambiguity with existing assignment syntax ⓘ
keep assignment expressions visually distinct from equality tests ⓘ
disallowsContext assignment expressions at top level of comprehension target list ⓘ
assignment expressions in some lambda parameter positions ⓘ
discussedOn python-dev mailing list ⓘ
python-ideas mailing list ⓘ
examplePattern [y := f(x) for x in data if y > 0] ⓘ
if (m := pattern.search(data)) is not None: ... ⓘ
while (line := file.readline()) != "": ... ⓘ
firstAppearedInVersion Python 3.8 ⓘ
governingBody Python core developers ⓘ
introducedFeature assignment expressions ⓘ
introducedOperator walrus operator ⓘ
introducedSymbol := ⓘ
language Python ⓘ
motivation allow assignment within larger expressions ⓘ
improve readability for some conditional and comprehension constructs ⓘ
reduce code duplication in certain patterns ⓘ
number 572 ⓘ
pepUrl https://peps.python.org/pep-0572/ ⓘ
referenceImplementation CPython 3.8 ⓘ
relatedConcept assignment ⓘ
comprehensions ⓘ
control flow ⓘ
expressions ⓘ
relatedPEP PEP 8 ⓘ
repository https://github.com/python/peps ⓘ
requiresVersionAtLeast Python 3.8 ⓘ
sponsor Guido van Rossum ⓘ
status Final ⓘ
syntaxChoiceReason use of := inspired by languages like Go and Pascal ⓘ
title Assignment Expressions ⓘ
type Standards Track ⓘ
useCase if statements that test and capture a value ⓘ
list comprehensions with reused subexpressions ⓘ
regular expression matches stored in a variable ⓘ
while loops that both test and assign ⓘ

How these facts were elicited

Referenced by (9)

Full triples — surface form annotated when it differs from this entity's canonical label.

PEP 622 → relatedTo → PEP 572 ⓘ
Assignment Expressions → alsoKnownAs → walrus operator (:=) ⓘ
linked to: PEP 572
Assignment Expressions → controversy → PEP 572 sparked significant discussion in the Python community ⓘ
linked to: PEP 572
Chris Angelico → coAuthorOf → PEP 572 ⓘ
Chris Angelico → notableWork → PEP 572: Assignment Expressions ⓘ
linked to: PEP 572
Python 3.8 → hasPEP → PEP 572 ⓘ
Standards Track PEPs → example → PEP 572 ⓘ