copying a file in the python script

Peter Otten __peter__ at web.de
Tue Apr 5 08:59:08 EDT 2005


Larry Bates wrote:

> If you are moving the file to another directory on the same hard
> drive (e.g. same filesystem) you can use os.rename(old, new) and
> the file doesn't have to be copied at all. This is more efficient.
> If you are copying to another filesystem, you must use shutil.copy
> and os.remove (or os.unlink).

Or use shutil.move() which implements the strategy you describe.

Peter 




More information about the Python-list mailing list