regular expression concatenation with strings

Jacek Trzmiel sc0rp at
Fri Jun 22 23:30:31 CEST 2007


oscartheduck wrote:
> I noticed a small error in the code (you referenced extension, which
> you had renamed to filenameRx), and when I corrected it I received the
> original error again.

I haven't had PIL installed, so I just commented out im.* calls for 
test. Just change: + ".thumbnail." + extension)
to: + ".thumbnail" + ext)

> What was it you were trying to do to solve the
> problem, though?

You can't use glob with regexps.  Instead use os.listdir() to get 
filenames and then rx.match() to find ones that does match the pattern.

Best regards,

More information about the Python-list mailing list