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

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 Spring MVC 4.0 RequestMapping无值,基于methodname   java Samsung 10 plus不允许wifi p2p发现   春爪哇。伊奥。IOException:找不到文件   java JasperReport饼图示例   java我试图使用mockito注释来测试我的代码,但无法解决mockito异常   命令行界面Java:制作简单的交互式cli应用程序   java jdk1之间的区别是什么。7_9 9和jdk1。7_271   java重载一个被重写的、继承的方法   java LazyInitializationException春季启动   java Play Framework 2.2.1 3个表之间存在大量关系