shutil module

Brad Hards bhards at bigpond.net.au
Mon Nov 18 05:53:16 EST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 18 Nov 2002 21:41, asdfasd asdfasdf wrote:
<snip>
> 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
>
<snip>
> i checked the output of glob and it says
>
> >>> glob.glob(r'c:\winnt\temp\events-*')
> ['c:\\winnt\\temp\\events-18-Nov-2002.txt']
I think that shutil.copy() expects a string( from info in 
http://www.python.org/doc/current/lib/module-shutil.html), while you are 
passing a one element list.

If you want it to copy all the matching files, you probably need to iterate 
over the list (in unix format):
>>> for file in glob.glob(r'./unpack/*'):
...     shutil.copy(file, '/tmp')

Alternatively, if you know that there will always be only one file, you could 
extract it with a slice operator.

I'm still getting into this - so this might be all wrong. But worth a thought, 
perhaps.

Brad

- -- 
http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE92MacW6pHgIdAuOMRAry5AJ9ndqTZaD5rtBH2hYRhPwiAsEjxywCfTQcc
mLwBpYQ0u/u20/Iyp8FZay0=
=Sue4
-----END PGP SIGNATURE-----





More information about the Python-list mailing list