Computer Science
In which order Python looks for the function/module names used by you.
Python Libraries
4 Likes
Answer
Python looks for the module names in the below order :
- Built-in Modules — Python first looks for the module in the built-in modules that are part of the Python standard library.
- Directories in sys.path — If the module is not found in the built-in modules, Python searches for it in the directories listed in the sys.path variable. The directories in sys.path typically include the current directory, directories specified by the PYTHON PATH environment variable, and other standard locations such as the site-packages directory.
- Current Directory — Python also looks for the module in the current directory where the Python script or interactive session is running.
Answered By
3 Likes
Related Questions
How are following import statements different ?
(a) import X
(b) from X import *
(c) from X import a, b, c
What is Python PATH variable ? What is its significance ?
What is the usage of help( ) and dir( ) functions.
Name the Python Library modules which need to be imported to invoke the following functions :
(i) log()
(ii) pow()
(iii) cos
(iv) randint
(v) sqrt()