module, you can manipulate the filesystem in a variety of ways:
creating, copying, and deleting files and directories, comparing
files, and examining filesystem information about files and
directories. This section documents the attributes and methods of the
os module that you use for these purposes, and
also covers some related modules that operate on the filesystem.
A file or directory is identified by a
string, known as its
path, whose syntax depends
on the platform. On both Unix-like and Windows platforms, Python
accepts Unix syntax for paths, with slash (
the directory separator. On non-Unix-like platforms, Python also
accepts platform-specific path syntax. On Windows, for example, you
can use backslash (
\) as the separator. However,
you do need to double up each backslash to
normal string literals or use raw-string syntax as covered in Chapter 4. In the rest of this chapter, for brevity,
Unix syntax is assumed in both explanations and
os supplies attributes that provide details
about path strings on the current platform. You should typically use
the higher-level path manipulation operations covered in Section 10.2.4 later in this chapter,
rather than lower-level string operations based on these attributes.
However, the attributes may still be useful at times:
The string that denotes the current directory ('
on Unix and Windows)
The default ...