Newbie Copy Question

Peter Hansen peter at engcorp.com
Wed Jun 9 19:54:36 CEST 2004


Stacy wrote:

> I'm new to Python (about 2 weeks) and I want to use the shutil module
> to copy files from Windows XP folders to my jump drive.  My problem is
> that I can't figure out how to make Python deal with the spaces in
> Windows folder and file names.  I tried putting the path in quotes
> (like you do at a DOS prompt) but still no good.  I searched
> python.org and can't find an answer....any ideas?

Please post an example of the paths that aren't working.  Spaces
generally work fine, but perhaps the limitation is with your
"jump drive" (what's that?) rather than with Python itself.
Another possibility is that you are using single backslashes
inside the Python strings, without realizing the effect this
has when certain characters follow the backslash...  this is
because of the "escape sequences" allowed in strings to let
a programmer produce special characters such as TAB (\t) or
LF (\n).  If that's the case, switching to forward slashes
should work, or learn to use raw strings as in r'path\file'.

-Peter



More information about the Python-list mailing list