Sumita Arora Solution

Explain the difference between import and from import statement, with example.

import <module> It import entire module and so everything inside the module will be imported like functions, constant, variables.In this way after importing the module we can use any function of imported module as per given syntax-module.<functionname>() For example import mathprint(math.pi)print(math.sum([10,20])) from <module> import statement from <module> import statement imports selected items , but to

Explain the difference between import and from import statement, with example. Read More »

Why should the form import statement be avoided to import objects?

We should avoid importing any object like from <module> import <object> because in this way object is added in current namespace and if any existing variable’s name resembles with the variable imported via module, so imported variable is ignored.

Why should the form import statement be avoided to import objects? Read More »

How are following import statement different?
(i) import X (ii) from X import * (iii) from X import a,b,c

import X It import entire X module and so everything inside the X module will be imported like functions, constant, variables.In this way after importing the module we can use any function of X as per given syntax-X.<functionname>() from X import * It import entire X module with all items, but to use these items

How are following import statement different?
(i) import X (ii) from X import * (iii) from X import a,b,c
Read More »

error: Content is protected !!
Scroll to Top