Import just what you need for the program.
For example:
So it becomes:
For example:
In [1]: import urllib In [2]: page = urllib.request.urlopen('http://python-forum.io') In [3]: html = page.read()Here I import the whole urllib module. But I am using only urlopen method. I do not need all the rest.
So it becomes:
In [1]: from urllib.request import urlopen In [2]: page = urlopen('http://python-forum.io') In [3]: html = page.read()