Getting all the *files* from a directory -- A better way??
piet at cs.uu.nl
piet at cs.uu.nl
Thu Mar 29 08:11:20 EST 2001
>>>>> scarblac at pino.selwerd.nl (Remco Gerlich) (RG) writes:
RG> Or even
RG> dir="a/b/c"
RG> files = [os.path.join(dir, f) for f in os.listdir(dir)
RG> if os.path.isfile(f)]
RG> If you do the map() with a list comprehension, why not the filter() as
RG> well.
Perhaps because it would have to be:
if os.path.isfile(os.path.join(dir, f))
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl
More information about the Python-list
mailing list