I've run into a bit of an issue iterating through files in python 3.0 and 3.1rc2. When it comes to a files with '\u200b' in the file name it gives the error...<br><p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Traceback (most recent call last):</span></font></p>


<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">  File "ListFiles.py", line 19, in <module></span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">    f.write("file:{0}\n".format(i))</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">  File "c:\Python31\lib\encodings\cp1252.py", line
19, in encode</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">    return
codecs.charmap_encode(input,self.errors,encoding_table)[0]</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">UnicodeEncodeError: 'charmap' codec can't encode character
'\u200b' in position</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">30: character maps to <undefined></span></font></p><p><br></p><p>Code is as follows...</p><p>import os<br><br>f = open("dirlist.txt", 'w')<br>
<br><br>for root, dirs, files in os.walk("C:\\Users\\Filter\\"):<br>    f.write("root:{0}\n".format(root))<br>    <br>    f.write("dirs:\n")<br>    <br>    for i in dirs:<br>        f.write("dir:{0}\n".format(i))<br>
    <br>    f.write("files:\n")<br>    <br>    for i in files:<br>        f.write("file:{0}\n".format(i))<br><br>f.close()<br>    <br>input("done")<br><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"></span></font></p>
<p><br></p><p>The file it's choking on happens to be a link that internet explorer created. There are two files that appear in explorer to have the same name but one actually has a zero width space ('\u200b') just before the .url extension. In playing around with this I've found several files with the same character throughout my file system. OS: Vista SP2, Language: US English.  <br>
<font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"></span></font></p><p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"><br></span></font></p>Am I doing something wrong or did I find a bug? It's worth noting that Python 2.6 just displays this character as a ? just as it appears if you type dir at the windows command prompt.<br>