Universal importing of modules?


#1

When importing modules such as ‘math’, why would we need to run ‘from math import *’ instead of ‘import math’? Does insert ‘import math’ at the start of your code not provide the math module for the whole code? Or if this command is meant to import everything from the math module, what does ‘import math’ exclude?


#2

One adds math to your namespace, the other adds

acos
acosh
asin
asinh
atan
atan2
atanh
ceil
copysign
cos
cosh
degrees
e
erf
erfc
exp
expm1
fabs
factorial
floor
fmod
frexp
fsum
gamma
gcd
hypot
inf
isclose
isfinite
isinf
isnan
ldexp
lgamma
log
log10
log1p
log2
modf
nan
pi
pow
radians
sin
sinh
sqrt
tan
tanh
tau
trunc

Which kind of pollutes your own namespace, you should rarely do this.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.