[Python-3000] New Import Behavior

Armin Ronacher armin.ronacher at active-4.com
Mon Jan 15 18:17:10 CET 2007


Hossa,

I like the python import system but it's limited at some point. Imagine you have
a large application with a plugin system and you want plugins to appear below
`applicationname.plugins` (Me and the pocoo team encountered that issue some
time ago when working on the pocoo component architecture).

Imagine the following package structure::

   yourapp/
     plugins/
       plugin1/
         __init__.py
         foo.py
       plugin2.py

And additional this one:

   thirdparty/
     yourapp/
       plugins/
         plugin3.py

`thirdparty` is in the pythonpath, the folder where in `yourapp` is in too.
If now someone tries to import `yourapp.plugins.plugin3` this would not work
because python stops the import process somewhere in `yourapp/plugins/` not
trying the `thirdparty` folder at all. For plugin systems this is very bad. Java
solves that better.

That limitation currently causes many packages polluting the root namespace in
site-packages that just act as plugins for other libraries or programs (trac
uses eggs as plugins, turbogears does etc)

The solution would be that python continues testing on the pythonpath if one
module in a package does not exist.

Regards,
Armin



More information about the Python-3000 mailing list