what is the difference between different importing options available in python
import time
from time import sleep
from time import *
When you import a module, three things take place. A new namespace is created that serves as a namespace for all the objects in the imported module. The code contained in the module is executed in that namespace. A name is created that refers to the module namespace, and the name matches the name of the module. Following is an interactive example:
[code=Python]>>> import time # Loads and executes the module "time"
>>> time.ctime() # Accesses a member of module "time"
'Mon Mar 24 19:49:39 2008'
[/code]To load a specific object from a module into the current namespace:
[code=Python]
>>> from time import ctime
>>> ctime()
'Mon Mar 24 19:49:55 2008'
[/code]To load all the objects from module time, except for those whose name starts with an underscore, into the current namespace:
[code=Python]
>>> from time import *
>>> clock()
2.5142860335601 313e-006
>>> [/code]
Comment