backslashes in test strings
Dr. Peter Stoehr
peter.stoehr at weihenstephan.org
Mon May 24 19:14:56 EDT 1999
Hi Fred,
Fredrik Lundh wrote:
>
> 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">
from my point of view it doesn't !
$ python
Python 1.5.2 (#46, Apr 22 1999, 22:16:33) [GCC egcs-2.91.60 19981201
(egcs-1.1.1 release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> a = r"c:=netreskit\sc"
>>> print a
c:=netreskit\sc
I think Chris just made a typo ...
Peter
--
---------------------------------------------------------------------------
Dr. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232
---------------------------------------------------------------------------
I'm the terror that flaps through the night
More information about the Python-list
mailing list