private static PermissionSet ps = new PermissionSet(PermissionState.None);
ps.AddPermission(new
SecurityPermission(SecurityPermissionFlag.Execution));
ps.AddPermission(new
FileIOPermission(FileIOPermissionAccess.PathDiscovery |
FileIOPermissionAccess.Read, Path));
public static vo
Hi Fernando,
try this:
ScriptEngine engine = ScriptRuntime.Create().GetEngine("py");
ScriptScope scope = engine.CreateScope();
scope.Execute(@"
def test(a):
return a
");
string my_a = "A";
object func = scope.GetVariable("test");
object result = engine.Operations.Call(func, my_a);
Console.Write
You can also find a blog post and a self containing sample on what you are
trying to do here -
http://blogs.msdn.com/seshadripv/archive/2008/06/30/how-to-invoke-a-python-function-from-c-using-the-dlr-hosting-api.aspx
Thanks
sesh
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL
You can do:
var runtime = ScriptRuntime.Create();
var scope = runtime.CreateScope("python");
scope.Execute(@"
def test(a):
return a
");
var test = scope.GetVariable>("test");
Console.WriteLine(test(my_a));
Tomas
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Please help me to call an IronPython function passing parameters from
a C# method.
Let's say I have a ScriptEngine and also a ScriptScope. In the scope I
have a Python function like this:
def test(a):
return a
Then in some C# method I have something like:
string my_a = "A";
How can I call
how can i restrict my user that he can not perform any imports or I/O
operations in the script.
--
View this message in context:
http://www.nabble.com/Restrict-imports-tp19113682p19113682.html
Sent from the IronPython mailing list archive at Nabble.com.
_
Hi Christian,
Hope these answer your questions...
>When accessing the baseScope from your example, isn't
>SymbolTable.IdToString(key) for each access to the baseScope slow?
>I wonder, why there is no ScriptScope.GetVariable(SymbolId) method.
The number of scenarios where a user would invoke any