June 17th, 2004, 07:25 PM
Easy question why no IsEmpty(dir)?
Really easy question but I can't figure it out. How to figure out if directory is empty or not? I thought there should be a IsEmpty method somewhere? Could somebody give me a hint please.
June 17th, 2004, 08:39 PM
You could always use os.listdir() and see if anything is returned. If nothing is returned, the dir is empty.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
June 17th, 2004, 10:26 PM
Another thing is that in python ( correct me if im wrong ) empty strings usualy return false... or you can use the filter function to compare your strings
June 17th, 2004, 11:49 PM
Just to expand on what was said here.. there is no IsEmpty in Python for a very simple reason, this is that any empty Python object i.e. an empty string, list, dict or any object that returns one of these values or None, is considered False. Kinda like having IsEmpty built into every single object!
Which helps keep your programs smaller and much cleaner in typical Python style
June 18th, 2004, 08:35 AM