[IronPython] Does IronPython 2.0 not recognize packages?

orip oripel at gmail.com
Tue Dec 2 14:16:18 CET 2008


If you have the following structure:

 Program.py
 PI
    /__init__.py
    /Authentication.py

an empty __init__.py will allow you to do:

  import PI.Authentication
  from PI import Authentication

If your __init__.py contains:
  import Authentication

Then you can do:
  from PI import *
and
  import PI
  PI.Authentication

'__all__' only works with symbols already defined in __init__.py
itself

On Dec 2, 10:34 am, "Yash Ganthe" <yas... at gmail.com> wrote:
> I am using IronPython 2.0 Release Candidate 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"]
> Authentication.py is in the PI folder.
>
> I replaced the erring line with :
> sys.path.append(r'.\PI')
> from Authentication import *
>
> and it worked.
>
> Does IronPython not recognize packages?
>
> Thanks,
> Yash
>
> _______________________________________________
> Users mailing list
> Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list