Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. var engine = Python.CreateEngine();
  2. engine.Execute("from System import *");
  3. engine.Runtime.Globals.SetVariable("property_value", "TB Test");
  4. engine.Runtime.Globals.SetVariable("result", true);
  5.  
  6. var sourceScope = engine.CreateScriptSourceFromString("result = property_value != None and len(property_value) >= 3");
  7. sourceScope.Execute();
  8.  
  9. bool result = engine.Runtime.Globals.GetVariable("result");
  10.  
  11. engine.Runtime.Shutdown();
  12.  
  13. global name 'property_value' is not defined
  14.  
  15. sourceScope.Engine.Runtime.Globals.ContainsVariable("property_value")
  16.  
  17. var engine = Python.CreateEngine();
  18. var scope = engine.CreateScope();
  19. scope.SetVariable("foo", 42);
  20. engine.Execute("print foo; bar=foo+11", scope);
  21. Console.WriteLine(scope.GetVariable("bar"));
  22.  
  23. var engine = Python.CreateEngine();
  24. engine.GetBuiltinModule().SetVariable("foo", 42);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement