Common sense works here: os
is a module, and os.path
is a module, too. So just import the module you want to use:
If you want to use functionalities in the os
module, then import os
.
If you want to use functionalities in the os.path
module, then import os.path
.
If you want to use functionalities in both modules, then import both modules:
import os
import os.path
For reference:
Lib/idlelib/rpc.py uses os
and imports os
.
Lib/idlelib/idle.py uses os.path
and imports os.path
.
Lib/ensurepip/init.py uses both and imports both.