backslashes in test stringsRý°?¶?®ý©???¦ý¯~³µ¤ý·?·?­$ìn

chris_barker at my-dejanews.com chris_barker at my-dejanews.com
Mon May 24 15:00:17 EDT 1999


In article <020901bea522$b07a78c0$f29b12c2 at pythonware.com>,
>
> oops.  did you forget that \n is a newline?
>
> starting with Python 1.5.2, you can use os.spawnv:
>
> status = os.spawnv(os.P_WAIT, "c:\\ntreskit\\sc", ("stop", serviceA))
> (untested)
>

There is a much niftyier way to dealk with the backslash problem. Use
Python's "raw" strings: ie:
status = os.spawn(os.P_WAIT, r"c:=netreskit\sc",("stop", serviceA))

prepending an r to a string tells python that it is a "raw" string, snd
that it shouldn't interpret the backslashes. This is VERY handy for
things like regular expressions!

-Chris


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




More information about the Python-list mailing list