trouble using "\" as a string

Ant antroy at gmail.com
Mon Aug 21 02:21:41 EDT 2006


> such as tempname="\"..it says that the line is single qouted.

The others have addressed the escape issue I think. However it looks
like you want the funtionality of the os.path module. For example:

>>> import os.path as path
>>> filename = "/home/ant/test.sh"
>>> filename2 = r"c:\python24\scripts\test.py"
>>> path.split(filename)
('/home/ant', 'test.sh')
>>> path.split(filename2)
('c:\\python24\\scripts', 'test.py')




More information about the Python-list mailing list