[issue42910] Wrong code appears in the type alias introduction

New submission from Casuall <Smile_zjk@qq.com>: I learned about type aliases on the page(https://docs.python.org/3/library/typing.html), and I found that following the code (Vector = list[float])in the tutorial, an error occurred (NameError: name 'typing' is not defined) when running. The following code has the same problem: ConnectionOptions = dict[str, str] Address = tuple[str, int] Server = tuple[Address, ConnectionOptions] I searched through google and found the correct code: from typing import List Vector = List[float] from typing import Dict, Tuple, Sequence ConnectionOptions = Dict[str, str] Address = Tuple[str, int] Server = Tuple[Address, ConnectionOptions] ---------- assignee: docs@python components: Documentation messages: 384944 nosy: Smile-zjk, docs@python priority: normal severity: normal status: open title: Wrong code appears in the type alias introduction _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue42910> _______________________________________

Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment: What version of Python did you use? This is a documentation for Python 3.9. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue42910> _______________________________________

Casuall <Smile_zjk@qq.com> added the comment: I am using python3.8, it turned out to be a version issue, sorry ------------------ 原始邮件 ------------------ 发件人: "Python tracker" <report@bugs.python.org>; 发送时间: 2021年1月12日(星期二) 晚上10:50 收件人: "破碎的冰"<Smile_zjk@qq.com>; 主题: [issue42910] Wrong code appears in the type alias introduction Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment: What version of Python did you use? This is a documentation for Python 3.9. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue42910> _______________________________________ ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue42910> _______________________________________

Change by Casuall <Smile_zjk@qq.com>: ---------- stage: -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue42910> _______________________________________
participants (2)
-
Casuall
-
Serhiy Storchaka