Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Brief IronPython 3.4 test
This is basically cribbed from the IronPython 3 page here, but adding some code to get LA variables (one from a dialog) into the Python code, and Python results back out to LA. Also changed the string concatenation to 'string.format()' syntax. I used 'Tools -> NuGet' to add the 'ironpython' package. I just entered for 'ironpython' in the dialog and it pulled 3.4, which is what I wanted (good thing, I don't even see IronPython 2 available on the NuGet Gallery page).
Copy      Help
/*/ nuget -\ironpython; /*/

string name = "";
var date = DateTime.Now.ToString("MMMM dd, yyyy");

if(!dialog.showInput(out name, "Enter your name for a greeting.", title: "Iron Python input test")) return;;

var eng = IronPython.Hosting.Python.CreateEngine();
var scope = eng.CreateScope();
def greetings(name, date):
    return 'Hello {}, today is {}'.format(name,date)
", scope);
dynamic greetings = scope.GetVariable("greetings");
// System.Console.WriteLine(greetings(name, date));"Output via IronPython", greetings(name,date), title: "IronPython at work", secondsTimeout: 10);


Forum Jump:

Users browsing this thread: 1 Guest(s)