How to import modules from the SciPy library? Suppose the io module is required.
1) Import the entire SciPy library:
import scipy 2) Import via from import:
from scipy import io 3) Importing the io module itself:
import io How to import modules from the SciPy library? Suppose the io module is required.
1) Import the entire SciPy library:
import scipy 2) Import via from import:
from scipy import io 3) Importing the io module itself:
import io scipy.io and io are different independent modules.
import scipy does NOT make all nested modules available. If you want to use the scipy.io module, then you need to explicitly import it:
import scipy.io The fact that you confused it with the io module from the standard library is a clear reason why from scipy import io should be avoided and leave this module in the scipy namespace.
To summarize: all three alternatives in the question are not accurate — use import scipy.io .
Option number 3 is not correct, since the io module will be standard and not from the scipy library.
You can import as you like, as long as you do not have the intersection of names.
Most scipy modules have specific names, so you can import them directly without worrying that they can intersect with other modules and variables.
The main thing is not to import everything from the library using * , as you will clog the entire scope.
Source: https://ru.stackoverflow.com/questions/595217/
All Articles