Solved

Difference of import usage in Python

Posted on 2016-11-16
1
15 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
1 Comment
 
LVL 15

Accepted Solution

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Installing Python 2.7.3 version on Windows operating system For installing Python first we need to download Python's latest version from URL" www.python.org " You can also get information on Python scripting language from the above mentioned we…
Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now