Python seems to have functions for copying files (e.g. shutil.copy
) and functions for copying directories (e.g. shutil.copytree
) but I haven't found any function that handles both. Sure, it's trivial to check whether you want to copy a file or a directory, but it seems like a strange omission.
Is there really no standard function that works like the unix cp -r
command, i.e. supports both directories and files and copies recursively? What would be the most elegant way to work around this problem in Python?
copytree
to copy a single file? – bobince