Message183751
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. |
|
Date |
User |
Action |
Args |
2013-03-08 16:56:33 | Piotr.Kuchta | set | recipients:
+ Piotr.Kuchta, ezio.melotti, eric.araujo, docs@python, jeffknupp, ashwch |
2013-03-08 16:56:33 | Piotr.Kuchta | set | messageid: <1362761793.14.0.357178539039.issue17383@psf.upfronthosting.co.za> |
2013-03-08 16:56:33 | Piotr.Kuchta | link | issue17383 messages |
2013-03-08 16:56:33 | Piotr.Kuchta | create | |
|