[IronPython] All classes that subclass a given type
fuzzyman at voidspace.org.uk
Sat Oct 30 03:37:14 CEST 2010
On 28/10/2010 19:15, Slide wrote:
> I am trying to find all the classes defined in Python that inherit
> from a C# class. I can iterate through the types in the ScriptScope
> using GetVariableName() and then checking if it's a PythonType object,
> but I don't know how to get the classes that it inherits from. Can
> anyone help out with this?
In normal Python you can call Class.__subclasses__() to get a list of
subclasses. I haven't tried this with .NET classes on IronPython though.
> Also, on a separate note, I would like to override the normal import
> mechanism to support new file extensions for modules (this is so I can
> associate the files with my application). Is this possible?
You can either patch __builtins__.__import__, use the ihooks module,
implement a PEP 302 import loader *or* use the IronPython Platform
Application Layer to control how IronPython imports are done (this is
how IronPython on Silverlight does imports from the xap file).
All the best,
More information about the Ironpython-users