I have an embedded scripting engine in my C# application that uses IronPython 2. I create the Python runtime and add a few classes to the global namespace so that the script
When you create the engine, you can add an "Arguments" option the contains your arguments:
IDictionary<string, object> options = new Dictionary<string, object>();
options["Arguments"] = new [] { "foo", "bar" };
_engine = Python.CreateEngine(options);
Now sys.argv
will contain ["foo", "bar"]
.
You can set options["Arguments"]
to anything that implements ICollection<string>
.
sys.argv is going to eventually be returning the actual parameters passed into the hosting app. Here's a few ways to solve this: