Re: regular expression concatenation with strings

2007-06-22 Thread oscartheduck
Oh dear. I just want to make it clear I wasn't trying to take credit for the change of extension to ext. I genuinely worked it out independently and then rushed back and posted about it, but you definitely worked it out and wrote it up first! Sorry! And thanks for the help!! James On Jun 22, 4

Re: regular expression concatenation with strings

2007-06-22 Thread oscartheduck
Got it: #!/usr/bin/env python from PIL import Image import glob, os, re size = 128, 128 def thumbnailer(dir, filenameRx): for picture in [ p for p in os.listdir(dir) if os.path.isfile(os.path.join( dir,p)) and filenameRx.match(p) ]: file, ext = os.path.splitext(picture) im

Re: regular expression concatenation with strings

2007-06-22 Thread Jacek Trzmiel
Hi, 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: im.save(file +

Re: regular expression concatenation with strings

2007-06-22 Thread oscartheduck
Shoot, I think I realised what I'm doing wrong. Let me write some code to address this, but I'm almost certain that the error is that I'm attempting to save an image with a regular expression, which is by nature fluid, tacked on to its ass after the .thumbnail. Which, now I look at your code, yo

Re: regular expression concatenation with strings

2007-06-22 Thread oscartheduck
Hi, 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. What was it you were trying to do to solve the problem, though? Thanks! On Jun 22, 2:41 pm, Jacek Trzmiel <[EMAIL PROTECTED]> wr

Re: regular expression concatenation with strings

2007-06-22 Thread Jacek Trzmiel
Hi, oscartheduck wrote: > I have a little script that sits in a directory of images and, when > ran, creates thumbnails of the images. It works fine if I call the > function inside the program with something like "thumbnailer("jpg), > but I want to use a regular expression instead of a plain strin

regular expression concatenation with strings

2007-06-22 Thread oscartheduck
Hi folks, I have a little script that sits in a directory of images and, when ran, creates thumbnails of the images. It works fine if I call the function inside the program with something like "thumbnailer("jpg), but I want to use a regular expression instead of a plain string so that I can match