Re: New plugin: randompic.py

Toby Smithe <[email protected]> Sat, 30 May 2009 15:04:40 +0100
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Hi, apologies for the bad threading; I was not previously subscribed.

I've fixed up the script now: indents are all four spaces, the import
statements come after the docstring, and the filename is chosen with
random.choice(..). I appreciate your comments; they're very useful.
There was one change I could not make, however:

Marius Gedminas wrote:
>> except: im = None
>>
>> if im is not None:
>> images.append(f)
>
>you could shorten that to
>
>for f in os.listdir(directory):
>try:
>images.append(Image.open(os.path.join(directory, f)))
>except:
>passhttp://fulltinreality.com/dev/pyblosxom/randompic.py

This won't work, as PIL.Image.open(...) does not return a filename,
nor an object that has the filename as an attribute, but an object of
class derived from PIL.ImageFile.ImageFile, which isn't very useful.

The new file is at http://fulltinreality.com/dev/pyblosxom/randompic.py

Thanks,

-- 
Toby Smithe :: http://fulltinreality.com

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com