Launch file in Notepad

Greg Krohn greg at invalid.invalid
Thu May 12 17:43:46 EDT 2005


George wrote:
> Newbie question:
> 
> I'm trying to lauch Notepad from Python to open a textfile:
> 
> import os
> b1="c:\test.txt"
> os.system('notepad.exe ' + b1)
> 
> However, the t of test is escaped by the \, resulting in Notepad trying 
> to open "c: est.txt".
> 
> How do I solve this?
> 
> (By the way, b1 comes from a command line parameter, so the user enters 
> c:\test.txt as command line parameter.)
> 
> George

The \t will only be interpreted as TAB if it was entered as part of
your python code. If the \t was entered as a command line arg it will
be interpreted as a \ and a t. For example:


#test.py
import sys
b1 = sys.argv[1]
b2 = "C:\test.txt"
print b1
print b2

will result in this:

C:\>test.py C:\test.txt
C:\test.txt
C:      est.txt


-greg



More information about the Python-list mailing list