On Mar 16, 12:12 pm, lampshade <[EMAIL PROTECTED]> wrote: > Hello, > > I'm having some problems with os.path.isdir I think it is something > simple that I'm overlooking. > > #!/usr/bin/python > import os > > my_path = os.path.expanduser("~/pictures/") > print my_path > results = os.listdir(my_path) > for a_result in results: > if os.path.isdir(str(my_path) + str(a_result)):
Not parts of the problem, but: (1) you don't need to use str() here. (2) use os.path.join instead of the + operator, if you are interested in portable code. > results.remove(a_result) > > for x in results: print x > > The problem is, that the directories are never removed. Can anyone > point out what I'm missing that is causing the bug? Is there a better > way of doing this? > > Thanks, You are removing directory *NAMES* from the container named "results". If you want to remove the directories from your filesystem, use os.rmdir. -- http://mail.python.org/mailman/listinfo/python-list