15

The FAQ that comes with IronPython 2.0.1 says the following:

You can define interfaces in C#, build those into a DLL, and then implement those interfaces in Python code as well as pass the python objects that implement the interfaces to C# code.

I have googled and googled and googled, but haven't found how to do this. Can someone help?

Michael
  • 8,362
  • 6
  • 61
  • 88
Rohit
  • 7,449
  • 9
  • 45
  • 55

1 Answers1

20

You can do it with the regular inheritance syntax of Python:

class SomeClass (ISomeInterface):
    def SomeMethod(self, parameter):
        pass

Just "inherit" the interface, implement its methods as you would any other class method, and enjoy!

Michael
  • 8,362
  • 6
  • 61
  • 88
Neil Williams
  • 12,318
  • 4
  • 43
  • 40
  • 4
    To implement properties in an interface, you would use `def get_SomeProperty(self):` and `def set_SomeProperty(self):` – Phil Jun 30 '11 at 18:27