Re: How to separate directory list and file list?
- From: Oliver Andrich <oliver.andrich@xxxxxxxxx>
- Date: Sun, 23 Oct 2005 17:25:11 +0200
Hi,
2005/10/23, Gonnasi <harddong@xxxxxxxx>:
> With
> >glob.glob("*")
>
> or
> >os.listdir(cwd)
>
> I can get a combined file list with directory list, but I just wanna a
> bare file list, no directory list. How to get it?
don't know if it is the best solution, but it looks nice. :)
path = "/home/test"
files = [fn for fn in os.listdir(path) if
os.path.isfile(os.path.join(path, fn))]
This gives you just the list of files in a given directory.
Best regards,
Oliver
--
Oliver Andrich <oliver.andrich@xxxxxxxxx> --- http://roughbook.de/
.
- Prev by Date: Re: Syntax across languages
- Next by Date: Re: How to separate directory list and file list?
- Previous by thread: Re: IDE recommendation please
- Next by thread: Re: How to separate directory list and file list?
- Index(es):
Relevant Pages
|