One of the well known tenets of Python is:
There should be one (and preferably only one) obvious way to do it.
There are plenty of places in the Python universe where this tenet is blatantly ignored, but none tickles me quite like shutil.copy and shutil.copy2. Both methods copy files from one location to another, with one (and apparently only one) difference, as the documentation for copy2
spells out:
shutil.copy2(src, dst, *, follow_symlinks=True)
Identical tocopy()
except thatcopy2()
also attempts to preserve file metadata.
I'd love to know what motivation the author of the (very poorly named) copy2
method had for adding it to the library. Was adding a preserve_metadata
argument to copy()
not sufficient for some reason? That's what any sane developer might have done.