Reputation: 10781
I'm trying to create a configuration file for a C# app in IronPython. Is there any way I can have that python file just return a value, or do I have to go through variables/functions to access the results of the script?
i.e., right now I've got Config.py that looks like
x = "test"
and C# code that goes
dynamic pyfile = Python.CreateRuntime().ExecuteFile("Config.py");
Console.WriteLine(pyfile.x);
Is there any way to remove the x?
Upvotes: 2
Views: 631
Reputation: 6486
You can create a ScriptSource with SourceCodeKind.AutoDetect and it will return the last expression in the file.
Upvotes: 3