[IronPython] 2.0B1 Hosting: Creating Python Types

Jeff Hardy jdhardy at gmail.com
Wed Mar 19 19:53:59 CET 2008


On Tue, Mar 18, 2008 at 9:49 PM, Dino Viehland
<dinov at exchange.microsoft.com> wrote:
> Evaling __builtins__ should work (or import __builtin__ and then eval that).

Evaluate, not Execute :). Thanks, Dino.

The code, for anyone else who's interested, is:
private static object MakePythonFile(ScriptEngine engine,
System.IO.Stream stream)
{
    return engine.Operations.Call(
        engine.CreateScriptSourceFromString("__builtins__['file']")
        .Compile().Evaluate(engine.CreateScope()),
    stream);
}



More information about the Ironpython-users mailing list