[IronPython] Determine the classes/interfaces a Python implements

Jeff Slutter jslutter at reactorzero.com
Mon Dec 15 21:14:51 CET 2008


I have a Python script that creates a class within it. This Python class
is derived off of a class, or interface, I made in C# - something like:

class MyClass(Test.MainForm.IScript):
    ...

Now, back in C#, I have gotten access to "MyClass" by:

object myclass = someScope.GetVariable("MyClass");

Is there a way to determine either:
a) what classes/interfaces MyClass implements OR
b) if it implements a specific class/interface

I want to know if the "object myclass" is supposed to implement
Test.MainForm.IScript or not.

I don't want to create an instance of MyClass as this would cause
problems, executing things I'm not ready to execute.

Also, related but not as important, implementing an interface (as above)
doesn't cause any compiler errors if I'm missing functions - is there a
way to enforce this?


Thanks,
Jeff



More information about the Ironpython-users mailing list