[IronPython] .NET can see Python classes?

Curt Hagenlocher curt at hagenlocher.org
Sun Aug 5 18:31:59 CEST 2007


On 8/4/07, Darren Govoni <darren at ontrenet.com> wrote:
>
>    Can .NET see python defined classes or objects? I define a class in
> Python
> but one of my .NET classes tries to find it via reflection and it cannot.
> I saw a post about this that is over a year old saying it was not then
> supported.
>

The fundamental issue here is that Python classes don't follow the same
semantics as CLR classes.  They are, for instance, mutable after
construction in ways that CLR classes are not.  In order to expose a Python
class directly to the CLR, it would have to be "frozen" in some manner, and
you might prefer to be able to specify the types of the parameters instead
of dealing with everything as "object".  This would require some sort of
non-Python syntax to accomplish.  Fortunately, there already is such a
thing: a CLR interface.  Define an interface in an external assembly and you
can derive from it in Python.  Your CLR classes can then access the Python
code through the interface.

--
Curt Hagenlocher
curt at hagenlocher.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070805/1115d238/attachment.html>


More information about the Ironpython-users mailing list