python Python PEPs ·

PEP 823 Proposes None-Aware Access Operators for Python 3.16

engineer
security feature patch

This Python Enhancement Proposal (PEP 823) introduces two new operators, `?.` for attribute access and `?[]` for indexing, designed to simplify handling of `None` values. These "None-aware" operators would evaluate the left-hand side, and only proceed if the result is not `None`, preventing `AttributeError` or `TypeError`. This aims to reduce boilerplate `is not None` checks and improve code readability, particularly for nested optional attributes or structured data traversal. The proposal is currently a draft targeting Python 3.16.

  • Security Implications
  • Add a maybekeyword
  • Change primaryrule to be right-recursive
Security (1)
  • Security Implications
Features (1)
  • Add a maybekeyword
Enhancements (1)
  • Change primaryrule to be right-recursive
Read the original announcement →

https://peps.python.org/pep-0823/

Related releases