From 6577a94c2a801cc565234ecf9d9fad6e6653be9f Mon Sep 17 00:00:00 2001 From: Jade <68784313+jang-hs@users.noreply.github.com> Date: Wed, 23 Sep 2026 11:39:23 +0900 Subject: [PATCH] PEP 526: Fix name mangling example Name mangling only applies inside a class body, so a module-level ``__points: int`` is stored as ``'__points'``, not ``'_Player__points'``. Move the annotation into the class and print its ``__annotations__``. --- peps/pep-0526.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/peps/pep-0526.rst b/peps/pep-0526.rst index ce822eb8e04..d3f0eafe7eb 100644 --- a/peps/pep-0526.rst +++ b/peps/pep-0526.rst @@ -438,13 +438,13 @@ Here is an example:: from typing import Dict class Player: - ... + __points: int players: Dict[str, Player] - __points: int print(__annotations__) - # prints: {'players': typing.Dict[str, __main__.Player], - # '_Player__points': } + # prints: {'players': typing.Dict[str, __main__.Player]} + print(Player.__annotations__) + # prints: {'_Player__points': } ``__annotations__`` is writable, so this is permitted::