shutil module

asdfasd asdfasdf s802645999 at yahoo.com
Mon Nov 18 05:41:25 EST 2002


hi all

i wanted to copy a file to another directory so i used the shutil module's copy() function. The name of this file will change everyday.eg, events-18-Nov-2002.txt and tomorrow will be events-19-Nov-2002.txt

i used:

import shutil

import glob

shutil.copy (glob.glob(r'c:\winnt\temp\events*'), r'c:\temp')

i couldn't seem to copy the file to c:\temp..it says

Traceback (most recent call last):
  File "<pyshell#132>", line 1, in ?
    shutil.copy(glob.glob(r'c:\winnt\temp\events-*'),r'c:\temp')
  File "C:\Python22\lib\shutil.py", line 61, in copy
    dst = os.path.join(dst, os.path.basename(src))
  File "C:\Python22\Lib\ntpath.py", line 190, in basename
    return split(p)[1]
  File "C:\Python22\Lib\ntpath.py", line 149, in split
    while i and p[i-1] not in '/\\':
TypeError: 'in <string>' requires character as left operand

i checked the output of glob and it says

>>> glob.glob(r'c:\winnt\temp\events-*')
['c:\\winnt\\temp\\events-18-Nov-2002.txt']

could it be the double slash that is making the fault....??

thanks for anyhelp

 

 

 

 



---------------------------------
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20021118/14d6af9e/attachment.html>


More information about the Python-list mailing list