[Tutor] Help return a pattern from list
Thomas C. Hicks
paradox at pobox.com
Tue Jul 6 01:40:28 CEST 2010
On Mon, 05 Jul 2010 20:29:02 +0200
tutor-request at python.org wrote:
> Date: Mon, 5 Jul 2010 13:54:55 -0400
> From: Vineeth Rakesh <vineethrakesh at gmail.com>
> To: tutor at python.org
> Subject: [Tutor] Help return a pattern from list
> <AANLkTimtfL0HdRJQrRZJxSyv8VeBwEHpvz_QDcJG4ftM at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> Hello all,
> Can some one help me to return a special pattern from a list.
> say list =
> now say I just need to return the files with .mp3 extension. How to
> go about doing this?
I use the fnmatch module:
for x in fnmatch.filter(fileList,pattern):
#do something to your files or list items here
More information about the Tutor