Difference of import usage in Python

I have below two usage

import div

Open in new window

and
from div import *

Open in new window


what is the difference between these two statement?

Thanks
beer9Asked:
Who is Participating?
 
Walter RitzelConnect With a Mentor Senior Software EngineerCommented:
As far as I can understand, the difference is how you can use the functions/classes inside the module being imported.
1.
import div
#to use any function inside div module, you should do this:
div.function_one()

Open in new window


2.
from div import *
#to use same function as above, you can do like this:
function_one()

Open in new window

1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.