How is this different from import math?
When we just use
import math, we are only telling Python to import the
math module, not necessarily all of the functions inside of it.
This is not the case when we use
from math import *. Now we’re saying to go into the module and import all of the functions possible, allowing us to use them all without needing to type
This can feel like it’s saving you time and effort, but be careful! As you’ll see in the next exercises, it can cause headache as well. What if you import a module’s entire function set and one of them has the same name as a function you’ve defined? This can cause tricky bugs because it won’t cause an error, it will simply behave in unexpected ways because you’ll have a hard time realizing which function with the same name is being used. Therefore it’s typically safer to import the functions you need, or just to stick with using the module prefix.