Python doesn't see the directories I create

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Aug 30 07:17:11 EDT 2007


Steve Holden a écrit :
> Bruno Desthuilliers wrote:
(snip)
>> You can avoid all escaping by using raw strings:
>>
>> mypath = r"C:\enhancement\rawfiles\"
>>
> Please note that the above is a well-known syntax error. A string 
> literal cannot end with a single backslash, as it escapes the closing 
> quote.

oops ! My bad :(
Thanks for the correction...

(snip)
>> Also and IIRC, using slash instead should also work, ie:
>>
>> mypath = r"C:/enhancement/rawfiles/"
>>
> That does indeed work in most situations, but ideally (i.e. for maximum 
> code portability) paths should be constructed using os.path.join(), or 
> collected from the environment somehow.

Indeed. But I doubt a path starting with 'C:' will work fine on a 
unix-like environment anyway !-)



More information about the Python-list mailing list