⚠️This implementation may be out of date or contain bugs. Last updated 2026-02-01.
PEPs 823 + 824 Implementation
Demo for PEPs 823 + 824
Explore the semantics of the proposals with this interactive WebAssembly demo.
Write Python code in the editor, run it in your browser, or experiment in the interactive REPL.
# Demonstrating PEP 823 None-aware operators
# and PEP 824 Coalescing operators
from dataclasses import dataclass
@dataclass
class Item:
name: str
price: float
@dataclass
class ShoppingCard:
items: list[Item] | None = None
@dataclass
class Customer:
name: str | None = None
card: ShoppingCard | None = None
discount: float | None = None
alex = Customer(
name="Alex",
card=ShoppingCard(
items=[
Item("Apples", 3.14),
Item("Bananas", 2.72),
]))
sandra = Customer(card=ShoppingCard())
for customer in (alex, sandra):
print(f"Customer: {customer.name?.upper()}")
customer.name ??= "Unknown customer"
print(f"Updated name: {customer.name}")
total = sum(
item.price for item in customer.card?.items ?? ()
)
print(f"Shopping card total: {total}")
first_item = customer.card?.items?[0]
print(f"First item in shopping card: {first_item}")
print("---")
Terminal Output
Interactive REPL
Note: This is an experimental WebAssembly build of Python.
Some features like networking, subprocesses, and threading are not available.
Please report issues regarding the demo or implementation to
the implementation repository
.
SharedArrayBuffer, which is required for this demo,
is not available in your browser environment. One common cause
of this failure is loading index.html directly in
your browser instead of using server.py as
described in
Tools/wasm/README.md
.
For more details about security requirements for
SharedArrayBuffer, see
this MDN page.