Michael wrote:
>
> 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__");
>

The one gotcha here is that for a SourceCodeKind of File we will set
__name__ in the generated code.  Instead creating the code like:

var code = Engine.CreateScriptSourceFromFile(filename,
                                  Encoding.Default,
                                  SourceCodeKind.Statements);

code.Execute(scope);

should result in __name__ not being overwritten.
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to