类型的功能

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中定义一个扩展类的属性   java找不到com的任何匹配项。安卓工具。建造:梯度:2.3+   使用Gradle axion发布的java在Windows上失败,但在Linux上工作   java Jboss Netty无法连续发送数据?   Java生成随机的1还是1?   java JLabel没有显示在我的JButton网格中   在Tomcat 8应用程序中使用多个连接池时出现java命名错误   将Spring Web App从tomcat 5.5迁移到tomcat 6.0时出现java问题   用JUnit测试受保护的java方法   java如何在windows中签出和构建UIAutomator源代码   java创建了一个成员函数/method/,它使原始数据类型的数组同时为int、double和String   YouTube数据API中java缺少execute()方法   Servlet容器中的java请求参数顺序   创建驾驶舱小部件时发生java SpagoBIsocket连接错误