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

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 bean不确定原因   多线程如果信号量锁获取/tryAcquire失败,如何使Java线程执行不同的任务而不是阻塞?   java编译器在同一目录中找不到其他类   在Java中,如何检查表示时间戳的字符串是否为有效日期?   java Commons vfs FindFile虚拟文件   TomcatJava。util。计时器空指针异常   java是在Oracle和Vertica之间移动数据的有效方法   java Adobe Acrobat Reader无法打开pdf文件,因为该文件不是受支持的文件类型,或者该文件已损坏   java使用usb驱动程序libusb、usb4java ecc。。为什么它如此不受支持?   java如何在第二列或特定列中插入jface TreeViewer?   java通过internet发送对象并调用其方法   带超声波传感器的Esp32Cam   java Cassandra分页问题最后一页的分页状态不正确   Java/WildFly/MongoDB/JAAS身份验证始终返回403禁止