Jesse Wiles wrote:
Hi,
I looked in the archives a bit but nothing jumped out.  I'm trying to
figure out how to set the __name__ for an embedded engine instance.
Here's what I'm working with...

__name__ should be set per scope. How about:

   scope.SetVariable("__name__", "__main__");

Michael
      // I'm guessing here; not sure what these options should be and
it was not obvious in tracing through the source
      //
      Dictionary<string, object> options = new Dictionary<string, object>();
      options["ExceptionDetail"] = true;
      options["ShowClrExceptions"] = true;

      ScriptEngine engine = Python.CreateEngine(options);

      // Again, grasping at straws...
      //
      IAttributesCollection symbols = new SymbolDictionary();
      symbols[Symbols.Name] = "__main__";
      ScriptScope scope = engine.CreateScope(symbols);

      scope.SetVariable("MyFooHash", new Dictionary<string, string>());

      engine.ExecuteFile(this.mPathTextBox.Text, scope);

Thanks,
Jesse Wiles
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to