os.system, backslash and commandline problem

Fredrik Lundh fredrik at pythonware.com
Wed Oct 31 02:39:58 EST 2001


Sharriff Aina <nhytro at t-online.de> wrote:

> Very strange answer Mr. Lundh, thanks all the same. I
> mentioned in the post that I know how to use raw strings
> and character ubstitution

if you knew how raw strings literals works, maybe you would
have used them correctly in your example?

and if you knew how escapes worked, maybe you wouldn't
have been so confused over why "\b" and "\f" appeared to
disappear from your strings.

and if you know how replace works, maybe you would be
puzzled by finding out that your code didn't work when you
used replace, but worked when you use os.path.normpath:

>>> file = "c:/the/boy.txt"
>>> os.path.normpath(file)
'c:\\the\\boy.txt'
>>> string.replace(file, "/", "\\")
'c:\\the\\boy.txt'

(in fact, the first line in normpath is path.replace("/", "\\"))

sounds like you're not telling us the whole story here.

</F>





More information about the Python-list mailing list