Solved

Difference of import usage in Python

Posted on 2016-11-16
1
83 Views
Last Modified: 2016-11-16
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
Comment
Question by:beer9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
Walter Ritzel earned 500 total points
ID: 41889613
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
any impressive Python code for a child? 3 137
merging 2 mysql databases with java 7 71
How To Loop - Python 19 100
Pass stdin text to Python subprocess 3 51
This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question