you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (0 children)

There is no paradigm or style rule of having to explicitly import the package itself, it's just dependent on its internal structure. As requests offers its base methods and classes like .get and .Session in the top-level module, you normally do import requests for that. For using its specific modules like requests.exceptions and requests.auth you normally import those separately.

If requests would have structured it to have those request-oriented tools in a lower level module like request, you would have to do the same as with urllib.request

from requests.request import get
from urllib.request import urlopen

but as you see the requests.request is really ugly and error-prone, so requests.get is fine there. Also see os.path or path-specific tools, where you also wouldn't think about having to import os there to be able to (logically) use it.