Hacker News new | ask | show | jobs
by z3t4 1232 days ago
Why not? It helps limiting variable scope. The advantage of a global variable without the disadvantages.
1 comments

Why not- possible to get an importerror if you make a mistake in the import statement. This kind of error should happen as early as possible and you won't expect it to happen during a random function call
If you're writing in a dynamically-typed, interpreted language like python, I think mistyping an import inside a function is really the least of your concerns when it comes to mistyping things.
It's also possible that the library isn't installed