10.12 distutils.file_util -- Single file operations
This module contains some utility functions for operating on individual files.
-
Copy file src to dst. If dst is a directory, then
src is copied there with the same name; otherwise, it must be a
filename. (If the file exists, it will be ruthlessly clobbered.) If
preserve_mode is true (the default), the file's mode (type and
permission bits, or whatever is analogous on the current platform) is
copied. If preserve_times is true (the default), the last-modified
and last-access times are copied as well. If update is true,
src will only be copied if dst does not exist, or if
dst does exist but is older than src.
link allows you to make hard links (using os.link) or symbolic links (using os.symlink) instead of copying: set it to
'hard'
or'sym'
; if it isNone
(the default), files are copied. Don't set link on systems that don't support it: copy_file() doesn't check if hard or symbolic linking is available. It uses _copy_file_contents() to copy file contents.Return a tuple "(dest_name, copied)": dest_name is the actual name of the output file, and copied is true if the file was copied (or would have been copied, if dry_run true).
- Move file src to dst. If dst is a directory, the file will be moved into it with the same name; otherwise, src is just renamed to dst. Returns the new full name of the file. Warning: Handles cross-device moves on Unix using copy_file(). What about other systems???
- Create a file called filename and write contents (a sequence of strings without line terminators) to it.
See About this document... for information on suggesting changes.