• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

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
0
beer9
Asked:
beer9
1 Solution
 
Walter RitzelSenior 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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now