Python Glossary Русский

all Python 3osterm

os.pathsep

constants

The separator of path lists in variables such as PATH: ':' on Unix and macOS, ';' on Windows.

Syntax

os.pathsep  # ':' на Unix, ';' на Windows

Not to be confused with os.sep: sep separates the components of one path, pathsep separates several paths in a single string. It is used to split PATH, PYTHONPATH and similar variables, and to build their value before launching a subprocess.

Examples

import os
print(repr(os.pathsep))  # → ? ':' на Unix, ';' на Windows
dirs = os.pathsep.join(['/usr/bin', '/bin'])
print(dirs.split(os.pathsep))  # → ['/usr/bin', '/bin']

See also

Open in the full glossarydocs.python.orgReport an inaccuracy