[IronPython] problem with import, packages, and IronPython 1.1

Pierre-Jules Tremblay pierrejules.tremblay at gmail.com
Mon Feb 2 22:50:30 CET 2009


We embedded IronPython 1.1 in our application.  Unfortunately I am running
into problems accessing .NET assemblies in Python.

In one situation, if I create a module (let's call it mymodule.py) and put
it in sys.path, with the following code in it:

import clr
from System.Diagnostics import Process

def foo():
     p = Process()
     return p

and then send the IronPython interpreter a script that imports mymodule and
calls foo(), everything works fine:

import mymodule
p = mymodule.foo()

However, if mymodule.py is "packaged" in a subdirectory, let's say "subdir",
which is in the search path as well and has an empty __init__.py file,
thinks break:

import subdir.mymodule
p = subdir.mymodule.foo()

I get: "ImportError: can't find module named Diagnostics".  It's as though
the fact that I've "packaged" the module in a directory breaks the way
IronPython gives me bindings to the .NET assemblies...  Why should this
break?  Am I doing something wrong?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090202/1b9cd6c5/attachment.html>

More information about the Ironpython-users mailing list