Submodule of module

from scipy import sparse as spr
from scipy.sparse import linalg

Here sparse has been imported in the first line. Is the second line still needed?

The second line is not needed because you can already access linalg as an attribute of the spr module, i.e. spr.linalg. And if you want to make linalg available in the current module namespace, do linalg = spr.linalg.

2 Likes