On 11/09/2012 04:46, Steven D'Aprano wrote: > On Mon, 10 Sep 2012 15:22:05 -0700, ruck wrote: > >> On Monday, September 10, 2012 1:16:13 PM UTC-7, Steven D'Aprano wrote: > [...] >>> That's not so much a workaround as the officially supported API for >>> dealing with the situation you are in. Why don't you just prepend a >>> '?' to paths like they tell you to? >> >> Good idea, but the first thing os.walk() does is a listdir(), and >> os.listdir() does not like the r'\\?\' prefix. In other words, >> os.walk(r'\\?\C:Users\john\Desktop\sandbox\goo') does not work. > > Now that sounds like a bug to me. If Microsoft officially support > leading ? in file names, then so should Python on Windows.
And so it does, but you'll notice from the MSDN docs that the \\? syntax must be supplied as a Unicode string, which os.listdir will do if you pass it a Python unicode object and not otherwise: import os os.listdir(u"\\\\?\\c:\\users") # and consequently for p, ds, fs in os.walk(u"\\\\?\\c:\\users"): print p TJG -- http://mail.python.org/mailman/listinfo/python-list