George said unto the world upon 2005-05-12 09:41: > 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?
There are several ways, but the preferred solution is to switch the slash direction: "c:/test.txt". Python's smart enough to notice its running on Windows and do the right thing with the slash. (Other choice include using raw strings: r"c:\test.txt", and explicitly escaping the backslash: "c:\\test.txt".) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list