Piotr Kuchta added the comment:

Eric, when you say 'the tutorial distinguishes between “it’s customary to put 
imports near the top of the file” vs. “later in the file”' the last bit is just 
your interpretation. The tutorial doesn't say "later in the file". Anyway, 
'later in the file' does not mean 'later in the file at the top level'.

For me an opposite to "top of the file" is "anywhere else in the file, 
including functions' and class' definitions later in the file".

Clearly, there is an ambiguity here. And I can tell you that people do get 
confused by that part of documentation. I know it from discussions with my 
colleagues at work. Also, I asked a question on StackOverflow, where I quoted 
the tutorial and gave that example of importing in a function body: 
http://stackoverflow.com/q/15283821/300886
You can see in the comments that people were surprised seeing the NameError! 
For me it is clear that this part of the tutorial should be improved.

----------

_______________________________________
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