[Tutor] About the vertical bar input

Mark Tolonen metolone+gmane at gmail.com
Tue Jun 30 03:13:29 CEST 2009


"hyou" <hyou00 at hotmail.com> wrote in message 
news:BLU143-DS478A37DC2B1DB050E5B96C4300 at phx.gbl...
> Hello,
>
> I'm trying to write a script that simply execute a command line like:
>
> C:\...(path)..\Devenv solution /build "Debug|Win32"
>
> However, in Python the "|" symbol is reserved thus I just can't make the
> command line above working once I added the "|" sign in it.
>
> How can I put the "original" vertical bar in a string?

Without an example of the code you are using, my guess is you are using 
os.system to execute a command on Windows.  The Windows shell (cmd.exe) uses 
veritical bar for the pipe command, which sends output from one program into 
the input of another.  The caret(^) is used in the Windows to escape special 
characters.  Example:

>>> import os
>>> os.system('echo Hello|World')
'World' is not recognized as an internal or external command,
operable program or batch file.
255
>>> os.system('echo Hello^|World')
Hello|World
0
>>>

-Mark




More information about the Tutor mailing list