> I've got this: > > ------- > def isBottomDir(path): > for item in os.listdir(path): > if os.path.isdir(os.path.join(path,item)): > return False > return True > ------- > > Is that an acceptable way of doing this?
Hi Simon, Your code looks good to me! > I've been reading http://thedailywtf.com for a month or so now - and > though I've yet to see a Python example cross their pages, I'm rather > terrified of becoming the first :) That web site (http://thedailywtf.com) is amusing in its way, but my problem with it is that so many of the people there enjoy mocking others in a mean-spirited and immature way. Programming well is a hard thing. The adolescent posturing I see there isn't admirable to me. It's also very sad to see that, for any given bad code, there's a lot more really bad responses. So my feelings are mixed about it, in the same sort of way that I have misgivings toward Slashdot. *grin* > To iterate through the directories, the following works for me: > > ------- > for root, dirs, files in os.walk('~\Test'): > if test_dir.isBottomDir(root) == True: print root > ------- > > Is it worthwhile trying to write my own recursive function for this? It's perfectly ok to take advantage of os.walk(); I like this code. Good luck to you! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor