imports after function definitions?

Hallvard B Furuseth (nospam nospam) h.b.furuseth at usit.uio.no
Fri Aug 29 13:04:01 EDT 2003


Terry Reedy wrote:
>in message news:HBF.20030828usgy at bombur.uio.no...
>> 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.

-- 
Hallvard




More information about the Python-list mailing list