[IronPython] Does IronPython 2.0 not recognize packages?

Michael Foord fuzzyman at voidspace.org.uk
Tue Dec 2 11:47:04 CET 2008


Yash Ganthe wrote:
> I am using IronPython 2.0 Release Candidate 2
>
>

Packages work fine with IronPython 2.

> >ipy Program.py
> Traceback (most recent call last):
> File "Program.py", line 22, in Program.py
> File "mscorlib", line unknown, in get_Item
> File "mscorlib", line unknown, in ThrowKeyNotFoundException
> KeyError: The given key was not present in the dictionary.
>
> Line 22 where it fails has:
> from PI import *
> I expect all modules from the PI folder to be loaded. The PI folder 
> has __init__.py which has the following line:
> __all__ = ["Authentication"]

This will cause Python to expect the name 'Authentication' to exist in 
the '__init__.py' file itself - which it won't unless that module 
imports it.

> Authentication.py is in the PI folder.
>
> I replaced the erring line with :
> sys.path.append(r'.\PI')
> from Authentication import *
>
This is *very* different to having __all__ = ["Authentication"] in the 
module. Try it without the sys.path manipulation and I think you will 
find it still works.

All the best,

Michael Foord
 

> and it worked.
>
> Does IronPython not recognize packages?
>
> Thanks,
> Yash
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


-- 
http://www.ironpythoninaction.com/




More information about the Ironpython-users mailing list