[IronPython] Importing .py files embedded as resources (from Silverlight)

Thibaut Barrère thibaut.barrere at gmail.com
Fri Jun 19 13:02:36 CEST 2009

Hi Jimmy,

> No special support; you'll have to iterate over all the files as resources,
> get their contents, and do the following:
> var scope = scriptEngine.CreateScope();
> scriptEngine.CreateScriptSourceFromString(code).Execute(scope);
> Though, why not just put the python files in the XAP? Then importing will
> just work, since the engine knows how to look in the XAP. If you're really
> hellbent on having them as resources, you could built a custom version of
> Microsoft.Scripting.Silverlight.BrowserPAL to look for files as embedded
> resources.

I just had a chat with Ivan and he suggested the same idea. For some reason
I thought that it would be hard to mix .py and .rb directly, but the
dlrconsole sample does that, it seems.

So I'm going to follow that advice and put the .py files into the XAP, and
let the engine do the job.

I still have one question then: if the main app file is a Ruby one, how can
I call the Python function from there ?

-- Thibaut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090619/fa78762c/attachment.html>

More information about the Ironpython-users mailing list