imports after function definitions?

Hallvard B Furuseth (nospam nospam) h.b.furuseth at usit.uio.no
Mon Sep 1 14:26:28 EDT 2003


Thanks for all the answers.

Peter Hansen wrote:
>Hallvard B Furuseth wrote:
>> I'm setting sys.path in a config function which depends on variables
>> near the end of the file.  So the config function must be called late,
>> and the imports that depend on it after that.
> 
> Sounds like the structure ought to be changed (IMHO).

OK, I did.  Moved the sys.path setting out of the config function.

> In other words, why do you need all those defines and all those
> variables to come before the imports?

I needed the config function to be called before the imports since
it set sys.path, and the config function should be able to access
some variables.  So the imports had to come after it, and after
those variables.  I thought it looked better to have the imports
at the end of the program than in the middle of it.

Never mind, though.  Now I have them right after the config function.
I want that one at the beginning because that's what people need
to edit.

-- 
Hallvard




More information about the Python-list mailing list