>>> os.path.realpath("C:")
'C:\\PythonApp'
>>> os.path.realpath("E:")
'E:\\'
My current directory is C:\PythonApp. It seems os defaults to the current directory if I give it an unknown path name for something like os.listdir so why does it work for E and not C?
Compare what you get with:
Windows saves a “current directory” for each drive, and
C:(without the slash) refers to that, not the root of the drive.The python docs for
os.path.joinmention this: