What is the Point of General Imports if I Can Just Use Universal Imports?


#1

What is the point of general imports if I can just use universal imports?


FAQ: Learn Python: Functions - Universal Imports
FAQ: Learn Python: Functions - Universal Imports
#2

Hi @christopherliu654513,

This answer might help: https://discuss.codecademy.com/t/how-is-this-different-from-import-math/338179?u=zystvan

from math import * will let you use the submodules directly, like sqrt(4). import math means you have to call the submodules as part of the math module, like math.sqrt(4).


#3

Both seem to do the same thing. However, the universal import doesn’t require the math. prefix. So, what’s the point of the general import if it does the same thing as the universal import but requires more text?


#4

I think that it said that the names could get confusing, or the names of functions and variables could accidentally share a name with something that you import.