 <p>Here is some related code which works for me (I have very long file names and paths):</p> <pre><code>for d in os.walk(os.getcwd()): dirname = d[0] files = d[2] for f in files: long_fname = u"\\\\?\\" + os.getcwd() + u"\\" + dirname + u"\\" + f if op.isdir(long_fname): continue fin = open(long_fname, 'rb') ... </code></pre> <p>Note that for me it only worked with a combination of all of the following:</p> <ol> <li><p>Prepend '\\?\' at the front.</p></li> <li><p>Use full path, not relative path.</p></li> <li><p>Use only backslashes.</p></li> <li><p>In Python, the filename string must be a unicode string, for example u"abc", not "abc".</p></li> </ol> <p>Also note, for some reason <code>os.walk(..)</code> returned some of the directories as files, so above I check for that.</p>