类型的功能

typish的Python项目详细描述


Build Status

键入

  • 用于彻底检查类型的功能
  • 考虑泛型的实例检查
  • typesafe duck键入

安装

pip install typish

内容

功能

FunctionDescription
^{}Returns whether ^{} is a sub type of all types in ^{}
^{}Returns whether ^{} is an instance of all types in ^{}
^{}Return the "origin" of a generic type. E.g. ^{} gives ^{}.
^{}Return the arguments of a generic type. E.g. ^{} gives ^{}.
^{}Return the ^{} alias for a type. E.g ^{} gives ^{}.
^{}Return the (generic) type of an instance. E.g. a list of ints will give ^{}.
^{}Return the closest common ancestor of the given instances.
^{}Return the closest common ancestor of the given classes.

类型

TypeDescription
^{}A generic Type var.
^{}A Type var for keys in a dict.
^{}A type var for values in a dict.
^{}The type of emptiness (= ^{}).
^{}The type of something unknown.
^{}The type of a module.
^{}The type of ^{}.

接口

typish.Interface定义接口。

示例:

Duck=Interface['walk':Callable[[],None],'quack':Callable[[],None]]

任何在接口中定义了正确类型的属性都是 视为该接口的实例(类、对象、甚至模块…)。

您可以使用内置的isinstancetypish.instance_of检查接口。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
不推荐使用java AmazonKinesisClient构造函数   java Quartz作业是否在同一个JVM中以自己的线程运行?   在Java中接收安卓推送通知以进行测试   java是对集合进行排序的最佳方法?   安卓 java。lang.NoSuchMethodError org。阿帕奇。http。客户乌提尔斯。我是杜提尔。encPath   java为什么while循环不以额外的“or”条件结束?   Python能否识别Java中使用BCrypt的哈希密码?   在Cygwin中使用附加Java库的windows   java无法从SQLite检索数据   java使用Swingworker给出不正确的结果   使用多线程服务器向特定客户端发送java消息   java在映射未知的Morphia中查询对象