to join a windows path, try
mypath=os.path.join('c:\\', 'sourcedir')
basically, you will need to escape the slash
to join a windows path, try
mypath=os.path.join('c:\\', 'sourcedir')
basically, you will need to escape the slash
The reason os.path.join('C:', 'src')
is not working as you expect is because of something in the documentation that you linked to:
Note that on Windows, since there is a current directory for each drive, os.path.join("c:", "foo") represents a path relative to the current directory on drive C: (c:foo), not c:\foo.
As ghostdog said, you probably want mypath=os.path.join('c:\\', 'sourcedir')
Windows has a concept of current directory for each drive. Because of that, "c:sourcedir"
means "sourcedir" inside the current C: directory, and you'll need to specify an absolute directory.
Any of these should work and give the same result, but I don't have a Windows VM fired up at the moment to double check:
"c:/sourcedir"
os.path.join("/", "c:", "sourcedir")
os.path.join("c:/", "sourcedir")