Adding a slash to Documents in os.join produces different results when I think it should not. Why?
Just trying to write code that does reasonable things for multiple users.
import os
# Initialize output files and folders, following principle of separating code from data
homeDir = os.path.expanduser('~')
targetDir = os.path.join(homeDir, '/Documents/Jeopardy/output')
print(targetDir)
# produces /Documents/Jeopardy/output which is not expected
targetDir = os.path.join(homeDir, 'Documents/Jeopardy/output')
print(targetDir)
# produces /home/max/Documents/Jeopardy/output which is expected
I expected both joins to produce /home/max/Documents/Jeopardy/output But the first one didn't. I must not understand the join doc, but I can't see why I get different outputs. thanks in advance