Net-informations.com
SiteMap  | About    

Does Python have C#/Java-style interfaces

No, python does not have any equivalent of interfaces . Since Python does support multiple inheritance, you can easily emulate the equivalence of interfaces. What that means is that interfaces are implicit in Python : if an object conforms to an interface, you can use it, no need to declare it like you would in statically typed languages such as Java or C# .

The closest thing is probably the abstract base classes module, which allows you to define common methods for a set of classes.

May be you can use something like the above. This will act as an abstract class . Every subclass is thus forced to implement myFunc().

Interfaces are concepts that belong to statically typed languages such as Java or C#, and do not really apply to dynamic language such as Python.









net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.