Saturday, June 10, 2006

Automatic Python imports with autoimp

I got sick of writing "import X" in Python. So, I created the public domain module autoimp, which imports all modules automatically:
>>> from autoimp import *
>>> os.stat('.')
>>> Image.open('test.bmp')
>>> pylab.plot([1,2],[3,4])
>>> scipy.linalg.eig([[1,2],[3,4]])
>>> ...
Thus one no longer needs to write "import X". It would take too long to load every module when one writes "from autoimp import *", so the imported modules are actually proxy objects which lazily load when they are first used.
(Module Website)

2 Comments:

Blogger Yaroslav said...

Cool, that looks useful

12:48 PM  
Blogger Connelly said...

See also Philip Eby's package Importing, described on Kevin Dangoor's blog post [1].

3:29 PM  

Post a Comment

<< Home