file/folder naming
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat Feb 19 01:38:40 EST 2011
On Fri, 18 Feb 2011 22:13:42 -0800, ecu_jon wrote:
> ok changed the try/except to just a file copy and got this:
> sourcepath is :
> [u'I:\\college\\spring11\\capstone-project\\facbac-009.py']
Note that it's a list.
> shutil.copy2(sourcepath,
> os.path.join(destpath,os.path.basename(files)))
Note that you are calling copy2 with the first argument as a list.
> TypeError: coercing to Unicode: need string or buffer, list found
Note that the error tells you exactly what is wrong.
> yes i see the list.
> but shouldnt this "for files in sourcepath:" parse thru the list ... ?
Yes it does. So what? You don't use files, you use sourcepath each time.
>>> source = ['a', 'bb', 'ccc']
>>> for x in source:
... print(len(source))
...
3
3
3
--
Steven
More information about the Python-list
mailing list