I found a similar way to do this, calling a method is much easier with it.
C # code is as follows:
IDictionary<string, object> options = new Dictionary<string, object>(); options["Arguments"] = new [] {"C:\Program Files (x86)\IronPython 2.7\Lib", "bar"}; var ipy = Python.CreateRuntime(options); dynamic Python_File = ipy.UseFile("test.py"); Python_File.MethodCall("test");
So basically I am sending the dictionary using the library path that I want to define in my python file.
So PYthon Script looks like this:
#!/usr/bin/python import sys path = sys.argv[0] #1 argument given is a string for the path sys.path.append(path) import httplib import urllib import string def MethodCall(OutputString): print Outputstring
So method invocation is now much easier with C # and passing arguments remains unchanged. Also with this code you can get a user library folder for a Python file, which is very good if you work on a network with a lot of different PCs
Vandeath
source share