file/folder naming

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Feb 19 00:37:51 EST 2011


On Fri, 18 Feb 2011 20:29:13 -0800, ecu_jon wrote:

> im trying to use wxpython to get a source file/files, then a destination
> folder to write them to. the file and folder picker works. the problem
> is, actually copying (actually shutil.copy2() ). i get an except error,
> as if the destination file name is not correct. looking at the print
> lines the destination looks right. i used os.path.join to join the
> folder path and the filebasename. i can hear it now, that this belongs
> on the wxpython page, and i will be posting there as well. but, im
> fairly certain its something in this "for files in sourcepath:"

>         try:
>             shutil.copy2(sourcepath,
> os.path.join(destpath,os.path.basename(files)))
>         except:
>             print "error file"

There's your problem there: by hiding the *actual* error message Python 
provides, and substituting a rubbish, useless, generic "error file" 
message, you make it impossible to see what causes the error.

Don't do that. Until you fix that, you can't diagnose errors, because the 
information needed to diagnose them is tossed away.


-- 
Steven



More information about the Python-list mailing list