python call external program (WHAT THE?!)
Berthold Hoellmann
hoel at GermanLloyd.org
Tue Sep 14 12:14:23 EDT 1999
Ben Thomas wrote:
>
> Hey guys the below is true with the addition of
> system('d:\\data\\vacman\\mybat.bat') = ok
>
> Have I found a bug? Do I get a t-shirt? :) Could a py-xpert explain to me my
> results?
>
> Ben
>python
Not a bug, a feature. The backslash has special meaning in python
strings:
Python 1.5.2 (#2, Jul 7 1999, 09:18:40) [C] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> print '\d'
\d
>>> print '\b'
>>> print '\m'
\m
>>> print 'ab\bcd'
acd
>>>
\b seems to be interpreted a backspace character, deleting the last
character. This is avoided by doubeling the backslash, or using
r(aw/egexp) strings, i.e. system(r'd:\data\vacman\mybat.bat'), but be
carefull, os.listdir (r'd:\data\vacman\') won't give, what you expect.
Cheers
Berthold
--
email: hoel at GermanLloyd.org
)
(
C[_] These opinions might be mine, but never those of my employer.
More information about the Python-list
mailing list