homedir, file copy

Westley Martínez anikom15 at gmail.com
Sun Jan 30 19:51:16 EST 2011


It seems like you are trying to copy directories with shutil.copy. Use
shutil.copytree instead.

On Sun, 2011-01-30 at 16:43 -0800, ecu_jon wrote:

> On Jan 30, 7:34 pm, rantingrick <rantingr... at gmail.com> wrote:
> > 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!
> 
> not nonchalant.
> i know i will ned to do testing and whatnot.
> just personally, i like to build stuff one concept at a time.
> for example, i had a problem with the homedir and peopel here helped
> me with that.
> now i have permissions problem, and an swer will likely meeerge.
> once i know how to copy a file, ill work on testing. like isfile and
> permissions.
> i know that has to be done. i guess its that you want tests before
> moves , and thats fine.
> since i have only ever had 1 python class, and basically learning this
> whole thing from scratch, i need to do things 1 step at a time.
> so now any thoughts on why i cannot write to my own homedir?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110130/ed6e9fc1/attachment-0001.html>


More information about the Python-list mailing list