On Apr 15, 2012, at 6:38 PM, Barry Warsaw wrote:
On Apr 15, 2012, at 02:12 PM, Glyph wrote:
Twisted has such a thing, mostly written by me, called twisted.python.modules.
Sorry if I'm repeating myself here, I know I've brought it up on this list before, but it seems germane to this thread. I'd be interested in getting feedback from the import-wizards participating in this thread in case it is doing anything bad (in particular I'd like to make sure it will keep working in future versions of Python), but I think it may provide quite a good template for a standard API.
The code's here: http://twistedmatrix.com/trac/browser/trunk/twisted/python/modules.py
The API is fairly simple.
from twisted.python.modules import getModule e = getModule("email") # get an abstract "module" object (un-loaded)
Got a PEP 8 friendly version? :)
No, but I'd be happy to do the translation manually if people actually prefer the shape of this API! I am just pointing it out as a source of inspiration for whatever comes next, which I assume will be based on pkg_resources. -glyph