从PEP 484键入[T],未实现Python 3.5输入模块。我如何检查班级类型?

时间:2016-05-19 18:31:36

标签: python python-3.5 type-hinting pep python-typing

因此,PEP 484有"The type of class objects"部分。

在本节中,声明可能存在以下情况:

U = TypeVar('U', bound=User)
def new_user(user_class: Type[U]) -> U:
    user = user_class()
    # (Here we could write the user object to a database)
    return user

我刚刚开始使用输入模块。我的问题是,当试图找到Type提示时,我找不到它。它在源代码或文档中没有任何地方。

release notes表示输入模块实现了PEP 484.没有迹象表明实现不完整。有没有办法在当前版本上做出这种类型的提示?或者现在根本不可能?

感谢。

0 个答案:

没有答案