Brian van den Broek wrote:

> > 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.

that's slightly misleading: on the API level, most functions can handle
both kinds of slashes.  functions like open(), os.remove(), shutil.copy()
etc. handles either case just fine.  and in most cases, this is handled
on the Win API level (or in the C library), not by Python.

however, in this case, the user passes a string to os.system().  that
string is passed *as is* to the command shell (which, in this case,
passes it on to notepad.exe as is).

</F>



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to