Launch file in Notepad
Richie Hindle
richie at entrian.com
Thu May 12 10:11:53 EDT 2005
[George]
> b1="c:\test.txt"
With this code, your problem is the embedded tab as you say. Use either
r"c:\test.txt" or "c:\\test.txt". However, if this is true:
> By the way, b1 comes from a command line parameter, so the user enters
> c:\test.txt as command line parameter.
then there will be no embedded tab. How are you prompting the user? When
I run this:
import os
b1=raw_input("Enter a filename: ")
os.system('notepad.exe ' + b1)
and enter c:\test.txt, it works as expected.
[Brian]
> 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.
In fairness to Windows, I don't believe Python does anything special here.
Windows itself happily accepts either forward slash or backslash at the OS
level - it's only the shells (explorer.exe or to a lesser extent cmd.exe)
that don't accept forward slashes.
--
Richie Hindle
richie at entrian.com
More information about the Python-list
mailing list