Python 3 type check not works with use typing module?

后端 未结 5 1114
时光取名叫无心
时光取名叫无心 2021-01-13 11:19

Why does type checking not work in Python 3?

I have done the following code with type checks or hints:

import typing

def hello(message: str):
    pr         


        
5条回答
  •  广开言路
    2021-01-13 11:38

    They are called "Type Hints" for a reason. Python just gives the option to mark types in a standard and structured way, to guide other programmers or to facilitate IDE error checking.

    However, Python doesn't enforce these Hints, nor there's any plan to, they are just that, not much more than comments.

提交回复
热议问题