Re: How can I get the names of the files in a directory?
From: .removethis. (_at_gmail.com)
Date: 01/15/05
- Next message: Roy Smith: "Re: java 5 could like python?"
- Previous message: Cameron Laird: "Re: java 5 could like python?"
- In reply to: Sara Fwd: "How can I get the names of the files in a directory?"
- Next in thread: Egor Bolonev: "Re: How can I get the names of the files in a directory?"
- Reply: Egor Bolonev: "Re: How can I get the names of the files in a directory?"
- Reply: Stian Soiland: "Re: How can I get the names of the files in a directory?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 15 Jan 2005 15:16:02 GMT
Sara Fwd said the following on 1/15/2005 8:10 AM:
> Can you guys also help me find a module that looks in
> a directory and print out the names of the files in there?
You can use glob:
>>> import glob
>>> from os.path import isfile
>>> print filter(isfile, glob.glob('/tmp/*')) # can use patterns
(will print a list of all files in the given directory, matching the
given pattern)
If you want to traverse a directory tree recursively, please take a look
at this recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/200131
Thanks,
--Kartic
- Next message: Roy Smith: "Re: java 5 could like python?"
- Previous message: Cameron Laird: "Re: java 5 could like python?"
- In reply to: Sara Fwd: "How can I get the names of the files in a directory?"
- Next in thread: Egor Bolonev: "Re: How can I get the names of the files in a directory?"
- Reply: Egor Bolonev: "Re: How can I get the names of the files in a directory?"
- Reply: Stian Soiland: "Re: How can I get the names of the files in a directory?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|