[Tutor] raw_input a directory path
Dave Angel
davea at ieee.org
Thu May 13 04:00:49 CEST 2010
Spencer Parker wrote:
> Here is the code:
> http://dpaste.com/hold/193862/
>
> <http://dpaste.com/hold/193862/>It still isn't working for me. I don't see
> it hitting the first for loop or even the second one. It runs without an
> error at all.
>
> I am inputing the directory as: \\Documents\ and\
> Settings\\user\\Desktop\\test
>
>
When using raw_input(), no characters are substituted and none need
escaping. It's not a literal to need double-backslashing, and it's not
a Unix shell, to need escaping of the space character. What you type is
what you get, other than things like backspace and enter.
Prove it to yourself with print, and then type it straight. You might
also add an extra (untested) :
if not (os.path.exists(directory) and os.path.isdir(directory)):
print "Not a valid directory"
DaveA
More information about the Tutor
mailing list