3 ms·
what is the point of this? you can just import inside function definitions: def antislash(A, b): from numpy.linalg import solve return solv
by enriquto 1y ago
what is the point of this?
you can just import inside function definitions:
def antislash(A, b):
from numpy.linalg import solve
return solve(A, b)
thus numpy.linalg is only imported the first time you call the antislash function. Much cleaner than a global import.
Ignore wrong traditions. Put all imports in the innermost scopes of your code!
- famouswaffles 1y agoThat's a hack that forces you to duplicate and hide imports. The tradition is to specify imports at the top because it's that much better readability wise.