imports after function definitions?

Hallvard B Furuseth (nospam nospam) h.b.furuseth at
Fri Aug 29 19:04:01 CEST 2003

Terry Reedy wrote:
>in message news:HBF.20030828usgy at
>> Is there any reason not to structure my program like this?
>>    def ...
>>    def ...
>>    var = ...
>>    var = ...
>>    import ...
>>    import ...
>>    main_function()
> It is helpful to human readers to see dependencies at the top and to
> know what globals are avaiable when reading defs.  What would be
> compensating gain of doing such?

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.


More information about the Python-list mailing list