homedir, file copy

rantingrick rantingrick at gmail.com
Sun Jan 30 19:34:20 EST 2011


On Jan 30, 5:43 pm, ecu_jon <hayesjd... at yahoo.com> wrote:
> ok now i get permission denied....

[...]

> shutil.copy (backupdir1, backupdir2)

I must stress the importance of proper testing before ever running
code that manipulates files! So many things can go wrong. Of course
you are just copying files here and not deleting them however you must
always be in the habit of treating files like explosives. And frankly
you're being quite nonchalant with this very naive approach to coding
and complete lack of testing.

When handling files always test, test, test. Never actually move,
copy, or delete until you are *absolutely* sure no failures will
occur. I will always do test runs that print out the action but DO NOT
actually DO the action, like...

Copying files:
 -- from: C:\\somefile1
      to: C:\\blah\\somefile1
 -- from: C:\\somefile2
      to: C:\\blah\\somefile2
 -- from: C:\\somefile3
      to: C:\\blah\\somefile3
 -- etc...

Once my test runs are bug free i can try to move or delete *one* file
from some test set. Once that is bug free then i will try the code on
many files of a test set, and ONLY THEN on the real thing. I guarantee
if you keep manipulating files in such a haphazard way you will live
to regret it!






More information about the Python-list mailing list