This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Piotr.Kuchta
Recipients Piotr.Kuchta, ashwch, docs@python, eric.araujo, ezio.melotti, jeffknupp
Date 2013-03-08.16:56:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1362761793.14.0.357178539039.issue17383@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-03-08 16:56:33Piotr.Kuchtasetrecipients: + Piotr.Kuchta, ezio.melotti, eric.araujo, docs@python, jeffknupp, ashwch
2013-03-08 16:56:33Piotr.Kuchtasetmessageid: <1362761793.14.0.357178539039.issue17383@psf.upfronthosting.co.za>
2013-03-08 16:56:33Piotr.Kuchtalinkissue17383 messages
2013-03-08 16:56:33Piotr.Kuchtacreate