[Python.NET] subclassing managed types in python

Tony Roberts tony at pyxll.com
Wed Oct 9 11:27:42 CEST 2013


Hi,

am I right in thinking that currently when managed types are subclassed in
python the python methods can't override the base class methods when called
from .net?

It would be useful to be able to do this for something I'm working on at
the moment, and before I started looking at it I wondered if anyone has
done any work on this before?

I think it should be possible to achieve by creating new managed types
using System.Reflection.Emit.TypeBuilder and replace any virtual methods
with ones that first look for a method on the python object with the same
name before falling back to the base class method - the same way SWIG
wrappers work for C++ classes basically but done dynamically. In the case
where there are multiple methods with the same name but different
signatures the python method would override them all and have to check what
it had been passed to do the right thing.

Any thoughts?

thanks,
Tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20131009/a5b57906/attachment.html>


More information about the PythonDotNet mailing list