Python question: Importing modules the purpose of "." | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python question: Importing modules the purpose of "."

Hi, Online, I saw this import urllib.request Is this having two libraries being imported together? Eg What is the difference between import urllib.request vs import urllib import request

19th Oct 2019, 12:24 AM
Terry
Terry - avatar
6 Answers
+ 1
urllib is a package and urllib.request is one of the four modules in that package. The documentation fir the urllib package can be found here: https://docs.python.org/3/library/urllib.html
19th Oct 2019, 12:34 AM
Brian R
Brian R - avatar
+ 1
If you would like to import the entire package, I believe you can just do: import urllib
19th Oct 2019, 12:38 AM
Brian R
Brian R - avatar
0
urllib.request is a single word. Its the name of a python module that is used to open urls.
19th Oct 2019, 12:29 AM
Brian R
Brian R - avatar
0
Ohh right, then is there a difference between urllib vs urllib.request?
19th Oct 2019, 12:31 AM
Terry
Terry - avatar
0
ok, if I import just urllib then would i get all the four modules? or I need to import all the modules separately?
19th Oct 2019, 12:36 AM
Terry
Terry - avatar
0
import urllib.request OR from urllib import request are the same
20th Oct 2019, 6:56 PM
Manoj
Manoj - avatar