views:

115

answers:

1

.net4.0

mytest.py

def Add (a, b):
    return a+b

I can use it in C# 4, like this:

        ScriptRuntime runtime = Python.CreateRuntime();
        dynamic script = runtime.UseFile("mytest.py");

        Console.WriteLine(script.Add(1, 3));

But, how can I use dynamic in F#?

open System
open Microsoft.Scripting.Hosting
open IronPython.Hosting

let call a b=
    let runtime = Python.CreateRuntime()
    let script = runtime.UseFile("mytest.py")
    script.Add(a,b)
+2  A: 

maybe this will help: F# and Iron Python

desco
Right, the key to "dynamic" in F# is to use the question-mark operator.
Brian