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 fou
shutil.copy
shutil.copytree
I suggest you first call shutil.copytree, and if an exception is thrown, then retry with shutil.copy.
import shutil, errno def copyanything(src, dst): try: shutil.copytree(src, dst) except OSError as exc: # python >2.5 if exc.errno == errno.ENOTDIR: shutil.copy(src, dst) else: raise