Since os
is a module instead of a package, import os.path
should fail. For comparison:
>>> import os.sys
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
import os.sys
ModuleNotFoundError: No module named 'os.sys'; 'os' is not a package
Note that os.sys
is available:
>>> import os
>>> os.sys
<module 'sys' (built-in)>
So, how does import os.path
work? Are there any other cases of something like this?
"os.path"
: github.com/python/cpython/blob/…