[python-win32] Question concerning wmi c.CIM_DataFile

Paul Keating keating at acm.org
Mon Jan 4 01:11:09 CET 2010


Don't do this:

#File to query       
string = "C:\DOCUME~1\profileName\LOCALS~1\Temp\\Temporary Directory 1 for deluxetreee (2).zip\Christmas.exe"
 
#Substitute "\" to "\\"
path = re.sub('\\\\', '\\\\\\\\', string)

I can see nothing wrong with this particular bit of code, but sooner or later doing this sort of thing will trip you up. Instead use a raw string (r"mys\t\ri\ng") that will leave your whacks intact. All you need is this:

path = r"C:\DOCUME~1\profileName\LOCALS~1\Temp\\Temporary Directory 1 for deluxetreee (2).zip\Christmas.exe"

I notice you have a doubled \ in path after Temp which may be the problem, depending on the target filesystem.

--
Paul Keating
The Hague 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100104/6e4735ce/attachment.htm>


More information about the python-win32 mailing list