backslashes in test strings

Fredrik Lundh fredrik at pythonware.com
Mon May 24 17:55:29 EDT 1999


I wrote:
> > 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!

but isn't it a bit weird that "=" maps to "\" in raw strings?

</F href="http://www.pythonware.com/people/fredrik/busy.htm">





More information about the Python-list mailing list