file/folder naming

Steven D'Aprano steve+comp.lang.python at
Sat Feb 19 07:38:40 CET 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\\']

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))


More information about the Python-list mailing list