8

Is there a proper platform-dependent (or independent?) path separator character somewhere in the Python standard library?

I am not asking about the directory separator / and \, but rather about the PATH separator: : and ;.

Java has java.io.File.pathSeparatorChar and java.io.File.pathSeparator to fulfill this need. Does Python have something similar? A fairly exhaustive search in os.path and pathlib docs yielded nothing, so I am beginning to lose hope.

I am not particularly hung up on the character itself. A function that behaves like os.path.join but for entire paths instead of path elements would be perfectly acceptable, preferable even.

0

1 Answer 1

18

Maybe this is what you're looking for:

import os

os.pathsep

os.pathsep is : or ; while os.sep is \ or /.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.