[IronPython] Interface in IronPython

Alex Willmer alex at moreati.org.uk
Tue Mar 13 00:37:21 CET 2007

On Mon, 2007-03-12 at 17:12 -0500, Ed Fialkowski wrote:
> Hi all, I'm pretty much totally new to IronPython and have come to
> the 
> point that I need an interface to interact with a co-worker's code, 
> but I can't seem to find any documents or discussion on syntax for 
> writing an interface. 

Do you mean calling an interface defined by your co-worker, or
implementing an interface in IronPython for you co-worker to call?

> Does anyone know of a link that talks about interfaces in IronPython 
> or feel like explaining one too me? :) 

To my knowledge you cannot create a class in IronPython to be consumed
by C# or VB. I don't know if an IronPython class can implement an

To call an explicitly implemented interface, or access the properties of
an explicit interface use the following:

ISomeInterface.MethodName(instance, args)
ISomeInterface.PropertyName.SetValue(instance, value)

As you've probably found attempting to cast, fails.

If you need to perform the equivalent of the C# expression 'instance is
ISomeInterface' (a QueryInterface?), then you'll find isinstance()
fails. Instead, for now use:


Here are a couple of relevant bug reports:


My thanks to Shri Borde for helping me understand this.

Regards, Alex

More information about the Ironpython-users mailing list