shutil.copy() vs shutil.copy2()
shutil.copy() and shutil.copy2() are both Python Shutil Module APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. shutil.copy(): Copies a file from src to dst (or into a directory). Its syntax is shutil.copy(src, dst, *, follow_symlinks=True), and it returns destination path string shutil.copy2(): Like copy() but also preserves metadata (timestamps, permissions). Its syntax is shutil.copy2(src, dst, *, follow_symlinks=True), and it returns destination path string Example of shutil.copy(): import shutil
shutil.copy("source.txt", "backup.txt")
shutil.copy("source.txt", "backup_dir/"). Example of shutil.copy2(): shutil.copy2("source.txt", "backup.txt"). Read the full references for shutil.copy() and shutil.copy2() to see parameters, edge cases, and example code side by side. Other Shutil Module APIs worth comparing: shutil.copytree(), shutil.move(), shutil.rmtree(), shutil.make_archive(), shutil.get_archive_formats(), shutil.disk_usage(). Both belong to the Shutil Module category in the Python Reference documentation.