UPDATE: kobra .NET for Python

Chetan Gadgil cgjunkaddr at attbi.com
Fri Jan 24 02:27:49 EST 2003


I have updated the "kobra" module to be more user friendly and added some
more features like limited support for arbitrary types in method calls.

Regards
Chetan Gadgil
cgjunkaddr at attbi dot com
chetangadgil at hotmail dot com

Here's an example session:

Usage

g>c:/Python22/python
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import kingkobra
>>> x = kingkobra.createObject("System.Xml", "System.Xml.XmlDocument")
kobra - A Python Wrapper for .NET
Copyright (C) 2003 Chetan Gadgil (chetan at gadgil dot net)
All Rights Reserved
>>> x.LoadXml("<hello>Good, this works!</hello>")
None
>>> y = x.CreateNavigator()
>>> y.ToString()
'Good, this works!'
>>>

Explanation

>>> import kingkobra

Import the beast.

>>> x = kingkobra.createObject("System.Xml", "System.Xml.XmlDocument")

Create a new System.Xml.XmlDocument object from the System.Xml.dll
Note that you can load any of your own .Net dlls. Just give the correct
absolute or relative path.

>>> x.LoadXml("<hello>Good, this works!</hello>")

Call the LoadXml method with a string arg. Currently tested args are int,
String, float, and String[]. However, a complex type should also work in an
arg.

>>> y = x.CreateNavigator()

Call "CreateNavigator()" on the XmlDocument object

>>> y.ToString()
'Good, this works!'
>>>

Future plans

Support calling into Python from .Net. e.g. callbacks etc. I have some ideas
on how to do this, but have not thought through in detail.


Applications

A .NET testing framework. You can script your own test cases with this
library, in conjunction with the "unittest" module of Python.






More information about the Python-list mailing list