[IronPython] Consuming Python Classes from C#

Tom Clancy tclancy at gmail.com
Fri Feb 17 15:19:31 CET 2006


Sorry if this is an obvious one, but I can't find a good resource on this. I
created a very simple Python class library in VS.NET2005 with one file
called HelloWorld.py that looks like this:

class Speaker:
    "Just a test to see if I can reference this"
    def __init__(self):
        pass

    def speak(self):
        return "Hello, world"

I built it and added it as a reference to a C# project (along with
IronPython). I can see a class named "HelloWorld", but cannot instantiate a
Speaker object or find a speak method inside the class through the object
browser. (I changed the name of the class to make it clearer what VS.NET was
seeing)

First off, should my class and filenames match exactly? I've never been
clear on that in Python and I feel like it's obscuring my actual problem
here. Second, while I see the HelloWorld class in the object browser,
whenever I fiddle with the Python code enough to reveal (what should be) a
class inside it, it's always static. Why would that be?

But my actual question is: how can I (best) create Python classes and
consume them in C#?

Thanks for digging through that ramble,

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060217/faecbc2c/attachment.html>


More information about the Ironpython-users mailing list