开发者

from java package how about in python?

开发者 https://www.devze.com 2023-03-08 14:45 出处:网络
I have search the ways that how can I define some thing like this in python OOP ways: j开发者_如何学JAVAava:

I have search the ways that how can I define some thing like this in python OOP ways:

j开发者_如何学JAVAava:

package project.work;
public interface IWork
{
    public void input();
    public void display();

}  


Python doesn't really have interfaces as separate from classes. You can use the abc module to get a similar effect. Discussion on that method and on some others is here.


Since python is a dynamically typed language it would seem silly to try this. The notion of interfaces really only makes sense in a statically typed language, in python you call a method on an object and find out at runtime if the object given actually implements the method.

0

精彩评论

暂无评论...
验证码 换一张
取 消