Python's driving me mad. Invalid token?
Pedro RODRIGUEZ
pedro_rodriguez at club-internet.fr
Fri Oct 18 02:59:19 EDT 2002
On Fri, 18 Oct 2002 08:37:17 +0200, Jim wrote:
> def CopyFiles(dirname,fnamelist):
> for name in fnamelist:
> destFile = open((dirname+"""\"""+name),'w')
^^
You have a quoting problem here, this could be "\\", but what
you actually need is :
> destFile = open(os.path.join(dirname,name),'w')
This is the portable way to build paths.
For the quoting problem can be spotted if you use a text editor
with syntax highlighting since the string wasn't closed.
Pedro
More information about the Python-list
mailing list