Éric Araujo added the comment:

Ah, we have it: the tutorial distinguishes between “it’s customary to put 
imports near the top of the file” vs. “later in the file”, and you interpret it 
as “it’s customary to put imports at the module top level” vs. “import in any 
scope e.g. functions”.  These are actually two different things, covered in 
different part of the docs: importing at module scope is very much recommended, 
as imports in functions can lead to nasty side-effects; and then there’s the 
style issue of putting imports at the beginning of the file, which is what the 
section we discuss is about.

----------
title: Error in documentation /2/tutorial/modules.html#more-on-modules -> 
Possibly ambiguous phrasing in tutorial/modules#more-on-modules

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17383>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to