Hi,
First, Sorry to all users which I mailed personally, this was not intentional.
It seems that, even after several years of being forced to use it, Outlook and
me are still not compatible. :-(
Von: Markus Schaber
> I want to set the __name__ variable to "__main__" in the script I execute.
> However, it seems that the __name__ variable always is overridden with the
> filename of the executed file.
It seems I found a way to do it:
ScriptEngine engine = Python.CreateEngine();
ScriptScope mainScope = engine.CreateScope();
ScriptSource scriptSource =
engine.CreateScriptSourceFromFile("test.py", Encoding.Default,
SourceCodeKind.File);
PythonCompilerOptions pco = (PythonCompilerOptions)
engine.GetCompilerOptions(mainScope);
pco.ModuleName = "__main__";
pco.Module |= ModuleOptions.Initialize;
CompiledCode compiled = scriptSource.Compile(pco);
compiled.Execute(mainScope);
Best regards
Markus Schaber
--
___________________________
We software Automation.
3S-Smart Software Solutions GmbH
Markus Schaber | Developer
Memminger Str. 151 | 87439 Kempten | Germany | Tel. +49-831-54031-0 | Fax
+49-831-54031-50
Email: [email protected] | Web: http://www.3s-software.com
CoDeSys internet forum: http://forum.3s-software.com
Download CoDeSys sample projects:
http://www.3s-software.com/index.shtml?sample_projects
Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade
register: Kempten HRB 6186 | Tax ID No.: DE 167014915
_______________________________________________
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users