Python os.path.join

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2010-03-11T05:38:19Z Indexed on 2010/03/11 5:43 UTC
Read the original article Hit count: 321

Filed under:
|
|

Hello, I am trying to learn python and am making a program that will output a script. I want to use os.path.join but am pretty confused (I know I am very bad at scripting/programming) See, according to the docs ( http://docs.python.org/library/os.path.html ) if I say

os.path.join('c:', 'sourcedir')

I get C:sourcedir as it's output. According to the docs, this is normal (right?)

But when I use the copytree command, Python will output it the desired way, for example

import shutil src = os.path.join('c:', 'src') dst = os.path.join('c':', 'dst') shutil.copytree(src, dst)

Here is the error code I get

WindowsError: [Error 3] The system cannot find the path specified: 'C:src/.'

If I wrap the os.path.join with os.path.normpath I get the same error

If this os.path.join can't be used this way, then I am confused as to its purpose

According to the pages suggested by Stack Overflow, slashes should not be used in join--that is correct I assume?

Thanks guys(girls) for your help

© Stack Overflow or respective owner

Related posts about python

Related posts about input