[IronPython] .NET can see Python classes?

Darren Govoni darren at ontrenet.com
Sun Aug 5 19:24:58 CEST 2007

I see. Currently, my python class extends a CLR class, but the python class is not resolvable from CLR. I want a CLR persistence engine
to be able to reflect on the python class as if it were a CLR class, but it says it cannot find the MyPython class created in my python script.
I guess my python classes also do not fall under a given CLR namespace either?

Now, if it were a pure interface implementation, I suppose its not possible to pass an instance of MyPython back to CLR to process as a normal
class instance (including reflection)?

thanks. I really like IronPython and it works great embedded in my app.

  ----- Original Message ----- 
  From: Curt Hagenlocher 
  To: Discussion of IronPython 
  Sent: Sunday, August 05, 2007 12:31 PM
  Subject: Re: [IronPython] .NET can see Python classes?

  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


  Users mailing list
  Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070805/49994aab/attachment.html>

More information about the Ironpython-users mailing list