other python ideas

Joshua Marshall jmarshal at mathworks.com
Fri May 4 11:15:58 EDT 2001


Douglas Alan <nessus at mit.edu> wrote:

> Well, unfortunately you can't do that in my code and never will be
> able to.  I don't put my imports at the top of the file -- I put them
> close to where the module is used, which is where the imports belong.
> (At least in my code, that's where they belong.)  There are all sorts
> of things that one might in some conceivable programming language put
> at the top of the file to make them more readily visible, but to me,
> keeping declarations close, when possible, to where the declared
> entity is used has almost always turned out to be the wisest thing.

And further, I find it useful to keep many imports inside function
definitions, so the importing is done lazily.  This also makes
circular module dependencies easy to deal with.



More information about the Python-list mailing list