PEP 823: None-aware access operators
This PEP introduces two new operators to the Python language to facilitate null-safe attribute and item access. These operators allow developers to access attributes or items on objects only if the object is not None, returning None otherwise.
Verified State Diff
Impact & Verification Analysis
Python software developers and library maintainers.
It reduces code complexity and the frequency of runtime errors related to NoneType objects, aligning Python's syntax with modern programming language standards for null safety.
Full Fact Overview
PEP 823 addresses the common boilerplate code required for checking None values before accessing attributes or dictionary keys. By implementing None-aware access operators (often referred to as safe navigation or null-coalescing operators in other languages like Swift or C#), Python aims to reduce the verbosity of conditional checks and minimize AttributeError exceptions. This change represents a significant shift in Python's syntax to improve code readability and safety when handling potentially null references in complex data structures.