提供接口类和其他接口实用程序。

good-interface的Python项目详细描述


良好的_接口

提供接口类和其他实用程序,这些实用程序可以定义方法“接口”,从而自动检查类和对象中的方法实现。

接口

接口是要在实现该接口的类中实现的方法的集合。接口类可以从类骨架定义接口。

fromgood_interfaceimportInterface@InterfaceclassMyInterface:defmethod1(self,arg1,arg2):passdefmethod2(self,arg2):pass

由于接口是可调用的,因此可以将新接口对象作为类的装饰器调用,该装饰器提供对给定类的检查,确保它在给定接口中实现定义的方法。

fromgood_interfaceimportInterface@InterfaceclassMyInterface:defmethod1(self,arg1,arg2):passdefmethod2(self,arg2):pass@MyInterfaceclassMyClass:defmethod1(self,arg1,arg2):passdefmethod2(self,arg2):pass

在另一个接口上调用该接口将扩展该接口,并将当前接口的方法添加到新接口中

fromgood_interfaceimportInterface@InterfaceclassMyInterface1:defmethod1(self):pass@MyInterface1@InterfaceclassMyInterface2:defmethod2(self,arg1,arg2):passdefmethod3(self,arg2):pass# Creates:## @Interface# class MyInterface2:#     def method1(self):#         pass##     def method2(self, arg1, arg2):#         pass##     def method3(self, arg2):#         pass

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

推荐PyPI第三方库


热门话题
如何加载。java文件到编译器?   java写入文件和I/O   java日历返回错误的当前日期安卓   if语句if变量等于1(java)   java很难让Joda有时间使用我的bukkit插件   json如何创建基于java的应用程序,该应用程序将从网站获取输入   java如何在多页中打印大型JPanel   java my spinner在添加从firebase数据库中选择的多个值时被覆盖   java用Play框架覆盖HTTP方法   试图获取所有用户时,java错误请求400。Dto和表格   java支持bean加载图像后javascript自动调用JS函数   java在MTOM的@StreamingAttachment(Metro)中,Parsely的意思是什么   具有可抢占线程队列的多线程java执行器   Java Opencv connectedComponentsWithStats   java如何向数组中添加2D数组的数目   eclipse为什么我的Java Zork克隆不能正确循环?   java在哪里放置定制的第二个web。xml   java如何更改最近应用列表中显示的快照?   java Browser#getText()返回空字符串