This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong code appears in the type alias introduction
Type: Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Smile-zjk, docs@python, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-01-12 14:43 by Smile-zjk, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg384944 - (view) Author: Casuall (Smile-zjk) Date: 2021-01-12 14:43
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]
msg384948 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-01-12 14:50
What version of Python did you use? This is a documentation for Python 3.9.
msg384954 - (view) Author: Casuall (Smile-zjk) Date: 2021-01-12 15:30
I am using python3.8, it turned out to be a version issue, sorry

------------------ 原始邮件 ------------------
发件人:                                                                                                                        "Python tracker"                                                                                    <report@bugs.python.org&gt;;
发送时间:&nbsp;2021年1月12日(星期二) 晚上10:50
收件人:&nbsp;"破碎的冰"<Smile_zjk@qq.com&gt;;

主题:&nbsp;[issue42910] Wrong code appears in the type alias introduction

Serhiy Storchaka <storchaka+cpython@gmail.com&gt; 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&gt;
<https://bugs.python.org/issue42910&gt;
_______________________________________
History
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87076
2021-01-12 15:32:53Smile-zjksetstatus: open -> closed
stage: resolved
2021-01-12 15:30:32Smile-zjksetmessages: + msg384954
2021-01-12 14:50:48serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg384948
2021-01-12 14:43:59Smile-zjkcreate