when to use import statements in the header, when to use import statements in the blocks where they are used?

Arnaud Delobelle arnodel at gmail.com
Fri Feb 10 05:46:41 EST 2012


On 8 February 2012 01:48, Lei Cheng <pat.inside at gmail.com> wrote:
> Hi all,
>
>    In a py file, when to use import statements in the header, when to use
> import statements in the blocks where they are used?
>    What are the best practices?
>    Thanks!

Aside from other answers: in some rare cases, importing within a
function can avoid circularity problems (e.g. A imports B which tries
itself to import A)

-- 
Arnaud



More information about the Python-list mailing list