[IronPython] PythonEngine.Import()

Kristof Wagemans kristof.wagemans at gmail.com
Sat Jul 29 12:25:12 CEST 2006


Is PythonEngine.Import() a hosting version of the python import statement?
It behaves differently and not all features of import are (yet?) exposed.

    PythonEngine pe = new PythonEngine();

    pe.LoadAssembly(Assembly.GetAssembly(typeof(System.Data.DataSet)));

    pe.Execute("import System.Data");    // Adds System to pe.Globals. This
is what I would expect.

    pe.Import("System.Data");    // Adds Data to pe.Globals.

 

Is PythonEngine.LoadAssembly() a good name for the method? It seems to
behave more like clr.AddReferenceXYZ then clr.LoadAssemblyXYZ. Also,
clr.LoadAssembly loads and returns an assembly while
PythonEngine.LoadAssembly() takes an assembly as parameter and returns
nothing.

 

The following code fails silently. Wouldn't it be better to throw an
ImportError exception?

    PythonEngine pe = new PythonEngine();

    pe.Import("DoesntExist");

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060729/708968fe/attachment.html>


More information about the Ironpython-users mailing list