Misunderstanding of python os.path.abspath
I have following code: directory = r'D:\images' for file in os.listdir(directory): print(os.path.abspath(file)) and I want next output: D:\images\img1.jpg D:\images\img2.jpg and so on But I get different result: D:\code\img1.jpg D:\code\img2.jpg where D:\code is my current working directory and this result is the same as os.path.normpath(os.path.join(os.getcwd(), file)) So, the question is: What is the purpose of os.path.abspath while I must use os.path.normpath(os.path.join(directory, file)) to get REAL absolute path of my file? Show real use-cases if possible. The problem is with your