Subject: python imports



This is an idea/suggestion,

When an import is issued from a chrome page, or a script imported from a chrome page. It should automatically look in the directory of the chrome page first for imports.

For example I have three firefox packages, that intercommunicate.

chrome/exe/content/exe.xul
chrome/exestandardfields/staticText/editoverlay.xul
chrome/exestandardidevices/freeText/editoverlay.xul

In the staticText overlay, the python script has to import another in the same dir.

To get around this, I've removed the "content" dirs of those directories, added "__init__.py" in all subdirs, inserted "chrome" at the beginning of sys.path, and to import, I changed "import component" to "from exestandardfields.staticText import component".

I guess this is an ok way of doing it actually, and maybe it would be confusing to know where "import component" came from.

Perhaps another way to make this nicer would be to have python assume, all chrome subdirs and jarfiles are python packages, without having to insert __init__.py files.

I'm undecided still.

Matthew Sherborne
exelearning.org


...



Programming list archiving by: Enterprise Git Hosting