regular expressions eliminating filenames of type foo.thumbnail.jpg

half.italian at gmail.com half.italian at gmail.com
Mon Jun 25 01:43:40 EDT 2007


On Jun 24, 10:00 pm, Justin Ezequiel <justin.mailingli... at gmail.com>
wrote:
> Why not ditch regular expressions altogether for this problem?
>
> [ p for p in os.listdir(dir)
>   if os.path.isfile(os.path.join(dir,p))
>   and p.lower().find('.thumbnail.')==-1 ]

I like `and '.thumbnail.' not in p]` as a better ending. :)

~Sean




More information about the Python-list mailing list