Mention that private variable annotations are mangled (#101)

(Implemented in http://bugs.python.org/issue28076, https://hg.python.org/cpython/rev/1c2a4f29e1ab.)
This commit is contained in:
Ivan Levkivskyi 2016-09-11 18:52:19 +02:00 committed by Guido van Rossum
parent ed31f2709a
commit c51c01869c
1 changed files with 6 additions and 3 deletions

View File

@ -384,16 +384,19 @@ evaluated::
In addition, at the module or class level, if the item being annotated is a
*simple name*, then it and the annotation will be stored in the
``__annotations__`` attribute of that module or class as a dictionary mapping
from names to evaluated annotations. Here is an example::
``__annotations__`` attribute of that module or class (mangled if private)
as a dictionary mapping from names to evaluated annotations.
Here is an example::
from typing import Dict
class Player:
...
players: Dict[str, Player]
__points: int
print(__annotations__)
# prints: {'players': typing.Dict[str, __main__.Player]}
# prints: {'players': typing.Dict[str, __main__.Player],
# '_Player__points': <class 'int'>}
``__annotations__`` is writable, so this is permitted::