Calling dotNet components from Python.
cgjunkaddr at attbi.com
cgjunkaddr at attbi.com
Mon May 12 08:23:18 EDT 2003
Yes, this is a transit glitch.
Since last month, I have moved to India. I was busy with the move
since my return from PyCon DC 2003.
Anyway, things being a bit crazy at work and my new place, have not
been able to set up my mail/newsgroup etc.
In fact I just got internet connectivity from home a couple of days
ago.
Anyway, KOBRA will allow you to call from Python into .NET and also
supports callbacks from .NET.
I have also added a couple of more useful features:
1) Import hooks to allow import of .NET classes using Python syntax:
(Syntax is similar to Brian Llyod's module - I liked it so didn't find
any reason to change it)
e.g.
from CLR.System.Xml.dll.System.Xml import XmlDocument
x = XmlDocument()
x.LoadXml("<hello>Testing</hello>")
etc.
2) I also have kobralib.true and kobralib.false as .NET booleans.
3) Array access using Python index
e.g.
in C#
string[] foo...
can be accessed as foo[0] etc
Slices are also supported.
4) Online compilation of C# code
i.e. you can compile c# code while in python.
This is for example, useful, when you want to test some C# code or you
want to build a helper module on the fly for use from python.
e.g.
import kobralib
assembly = kobralib.helper.compileCS("namespace Foo { class Bar {} }",
"xx.dll", inMemory=kobralib.true)
barInstance = assembly.CreateInstance("Foo.Bar")
etc.
I have found this to be very useful too.
I will post the new hosting information this week.
Regards
Chetan
Alex Martelli <aleax at aleax.it> wrote in message news:<Ldura.19534$3M4.565359 at news1.tin.it>...
> Paradox wrote:
>
> > I was wondering if it is possible to call a dotNet dll written in C#
> > from within a Python script. If anyone knows of any documentation or
> > example code that accomplishes something like this. It seems that you
> > can call a com component but all my searching on dotNet has not found
> > anything about using dotNet components in Python. Thanks
>
> There's a project by Chetan Gadgil called Kobra for this purpose, but
> right now I cannot access its page,
> http://home.attbi.com/~chetangadgil/DotNetWrapperForPython.htm -- I
> hope it's just some transient glitch.
>
>
> Alex
More information about the Python-list
mailing list