Re.Re: os.system, backslash and commandline problem

David Bolen db3l at fitlinxx.com
Tue Oct 30 20:17:48 EST 2001


nhytro at t-online.de (Sharriff Aina) writes:

> Very strange answer Mr. Lundh, thanks all the same. I mentioned in the =
> post that I know how to use raw strings and character substitution, did =
> you read my post?

For what it's worth, it was reading your post that made me think of
the same answer as Fredrik, since you specifically commented on how
the path "was trashed" when you tried printing the string where you
hadn't properly quoted backslash characters.  Given that having
literal tabs (\t) and backspaces (\b) in a string and then printing it
is bound to look strange, your use of "trashed" made it sound like you
didn't understand why it looked that way or thought that was the
source of your problems.

(Oh, and I just re-read it and can't find any mention of "raw strings"
 in the original post, either knowing about them or not)

> Anyways, someone adviced me to use "os.normpath" instead of replacing
> the backslashes, that worked well with "os.system"

I'm guessing that the "options" that you were complaining about losing
were also forward slashes (Windows?), and in the same tk widget get()
call that retrieved the path information as well, so your global
replace of all forward slashses with backslashes also changed options
into non-recognizeable.  Otherwise, your replacement should have
worked as well as normpath, although normpath is more portable.

For what it's worth, the underlying Windows API can technically accept
forward slashes in paths as well, so in many cases you can just stick
with forward slashes and still be portable (at least to Windows and
Unix).

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list