I'm trying to open a path to file with some application. The problem is that the path contains various control characters that make it difficult to open the file. The following code shows my last attempt which prefixes control characters with \ but it strangely opens the file many times (like in endless loop).
path = path.replace("'", "\\'")
path = path.replace("(", "\\(")
path = path.replace(")", "\\)")
try:
os.system("%s %s 2>/dev/null &" % (appForExtension[extension], path))
except:
print "not opened"
Do you know how to standardly open the file with os.system() call avoiding the problems with control characters?