problems with opening files due to file's path
Carsten Haese
carsten.haese at gmail.com
Wed Jun 11 16:57:32 EDT 2008
Alexnb wrote:
> I don't get why yall are being so rude about this.
We're frustrated with your apparent inability to understand anything
we're saying.
> My problem is this; the
> path, as a variable conflicts with other characters in the path, creating
> escape characters I don't want, so I need a way to send the string to the
> os.startfile() in raw, or, with all the backslashes doubled.
No, no, no, no, NO! That is not your problem! You are drawing unfounded
conclusions from the fact that you had to double up backslashes when the
filename came from a string literal. The situation is entirely different
when the filename comes from user input. No doubling up of backslashes
is necessary when the filename comes from user input. TRUST ME!
For simplicity, start with this code to convince yourself:
import os
filename = raw_input("Please enter a filename: ")
os.startfile(filename)
Once you get that to work, replace raw_input with a function that gets
the filename from your GUI.
Hope this helps,
--
Carsten Haese
http://informixdb.sourceforge.net
More information about the Python-list
mailing list