os.path.walk usage on WinXP

Alex Popescu nospam.themindstorm at gmail.com
Thu Jul 26 13:29:55 CEST 2007

Alex Popescu <nospam.themindstorm at gmail.com> wrote in
news:Xns997991CDF7710themindstorm at 

> Hi all!
> I am trying to use the os.path.walk function, but I am getting a weird
> error:
> def _walk(dir_name):
>   def selector(arg, dirname, fnames):
>     print "selector"
>   os.path.walk(dir_name, selector, None)
> File "C:\zengarden\python\python25\lib\ntpath.py", line 325, in walk
>    names = os.listdir(top)
> TypeError: coercing to Unicode: need string or buffer, list found
> After searching through the documentation the only thing that I've
> found is the comment on os.listdir(path):
> [quote]
> Changed in version 2.3: On Windows NT/2k/XP and Unix, if path is a
> Unicode object, the result will be a list of Unicode objects.
> [/quote]
> Unfortunately, I have no idea what to do next. 
> TIA,
> ./alex
> --
> .w( the_mindstorm )p.
Apologies to everyone for the noise: the dir_name param proved to be a 
list and not a string as expected.

.w( the_mindstorm )p.

More information about the Python-list mailing list