[IronPython] Embedded IronPython 2.6 Module Name
curt at hagenlocher.org
Thu Nov 5 19:45:19 CET 2009
I'm not sure if there's a simpler way -- here's what I did a few months back
when I needed to publish something via __main__:
pythonContext = HostingHelpers.GetLanguageContext(self._engine)
module = pythonContext.CreateModule()
scope = HostingHelpers.CreateScriptScope(self._engine, module.Scope)
HostingHelpers is a class in the DLR hosting interfaces. From C#, you'd need
to explicitly cast the LanguageContext to a PythonContext.
After this, you would run your Python code within the "scope" ScriptScope.
On Thu, Nov 5, 2009 at 10:57 AM, Jonathan Howard <jhoward at drawloop.com>wrote:
> We're trying to upgrade to IronPython 2.6 and are having a number of issues
> with it. The biggest issue is there doesn't appear to be a way to name the
> module that runs when you embed your code. We're using the Hosting API to
> create and run code within C#. The code runs, but we have other modules
> that are supposed to pull globals from the __main__ module. This worked in
> 1.1 by setting the DefaultModule on the PythonEngine instance. There
> doesn't seem to be a way to do this anymore.
> Any help would be appreciated.
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users