Proposal: Inline Import

Benji York benji at benjiyork.com
Fri Dec 9 15:17:01 EST 2005


Shane Hathaway wrote:
> I'd like a way to import modules at the point where I need the 
> functionality, rather than remember to import ahead of time.  This might 
> eliminate a step in my coding process.  Currently, my process is I 
> change code and later scan my changes to make matching changes to the 
> import statements.   The scan step is error prone and time consuming. 
> By importing inline, I'd be able to change code without the extra scan step.

> Thoughts?

Why not: 1) jump to the top of the file when you need to do an import 
(1G in Vim), 2) add the import, 3) jump back to where you were (Ctrl-o 
in Vim) and keep coding.  This isn't Vim specific, I suspect all decent 
editors have similar capabilities (I know Emacs does).  Thus eliminating 
the unpleasant scan step.

Oh, and py.std does something similar to what you want: 
http://codespeak.net/py/current/doc/misc.html#the-py-std-hook.
--
Benji



More information about the Python-list mailing list