So I was wondering, at this point in time I'm reading a book about Python. The book explains the following:
The import algorithm
To truly understand namespace packages, we have to look under the hood to see how the
import
operation works in 3.3. During imports, Python still iterates over each directory in the module search path,sys.path
, just as in 3.2 and earlier.
My question is: How is python able to iterate through sys.path
when sys is not imported. Also if python is able to see sys
without import to iterate through sys.path
why do we need to import sys
in our code?
>>> sys
NameError: name 'sys' is not defined.
>>> import sys
>>> sys
<module 'sys' (built-in)>