[Python.NET] How to manipulate python module property from C#?
Brian Lloyd
brian.lloyd at revolutionhealth.com
Fri Feb 8 21:22:16 CET 2008
imports are case-sensitive, so you probably have to do
ImportModule("Hello").
-Brian
On 2/8/08 10:16 AM, "Charles Chiu" <charles5557 at yahoo.com> wrote:
> Hi Everyone,
> I just found out python for .net yesterday and
> would be interested in knowing about this. I have
> tried to test it myself however, i couldn't figure out
> what is wrong with the code i wrote. I am trying to
> invoke a simple method hello() from Hello.py
> here is the code i wrote:
>
> namespace PyWrapper
> {
> class Program
> {
> static void Main(string[] args)
> {
> PythonEngine.Initialize();
> PyObject sys =
> PythonEngine.ImportModule("sys");
> string actual_path =
> sys.GetAttr("path").ToString();
> Console.WriteLine(actual_path);
> string path = "my path to the py file";
>
> PyObject hello =
> PythonEngine.ImportModule("hello");
> // PyObject hello remins null after the
> line above which i suspect that is the reason the next
> line crashes.
> string fromPython =
> hello.InvokeMethod("hello", new PyTuple()).ToString();
> PythonEngine.Shutdown();
> }
> }
> }
>
> Can someone give me some suggestion on what kind of
> problem this could be? thanks
>
>
>
> ______________________________________________________________________________
> ______
> Looking for last minute shopping deals?
> Find them fast with Yahoo! Search.
> http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet
--------------------------
Brian Lloyd
brian.lloyd at revolutionhealth.com
More information about the PythonDotNet
mailing list