|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Easy question why no IsEmpty(dir)?
Hi,
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. Thanks Random |
|
#2
|
||||
|
||||
|
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 Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month Looking for a perl job with kick-*** programmers in a well-known NASDAQ listed tech company with branches in the US and Europe? We're hiring. PM me for details. Requirements |
|
#3
|
||||
|
||||
|
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
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#4
|
||||
|
||||
|
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 ![]() Mark. |
|
#5
|
|||
|
|||
|
Thanks for your help.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Easy question why no IsEmpty(dir)? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|