>>>>> aberry <abe...@aol.in> (a) a écrit: >a> I am facing an error on Unicode decoding of path if it contain a folder/file >a> name starting with character 'u' .
>a> Here is what I did in IDLE >a> 1. >>> fp = "C:\\ab\\anil" >a> 2. >>> unicode(fp, "unicode_escape") >a> 3. u'C:\x07b\x07nil' >a> 4. >>> fp = "C:\\ab\\unil" >a> 5. >>> unicode(fp, "unicode_escape") >a> 6. >a> 7. Traceback (most recent call last): >a> 8. File "<pyshell#41>", line 1, in <module> >a> 9. unicode(fp, "unicode_escape") >a> 10. UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position >a> 5-9: end of string in escape sequence >a> 11. >>> >a> Not sure whether I am doing something wrong or this is as designed behavior >a> . >a> any help appreciated Calling unicode(fp, "unicode_escape") with these filenames is nonsense. unicode_escape is for transforming a string like \u20ac to a €-sign or vice versa: >>> fp="\\u20ac" >>> print unicode(fp,"unicode_escape") € So what are you trying to achieve? -- Piet van Oostrum <p...@cs.uu.nl> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list