[Tutor] filelist
richard kappler
richkappler at gmail.com
Sun Aug 5 03:11:52 CEST 2012
Starting to work through "Programming Computer Vision with Python" in my
-summer of learning python- quest. As I read through the intro to the PIL
library, I came across the below code. When I read it, I said to my self
"I don't see how that calls a set of files, there's no specificity. How
does that know where to call from?" Then I convinced myself that, because
I'm a beginner, I must be missing something, and ran it through the
interpreter. Of course, I got an error message telling me filelist isn't
defined. But now I'm kinda lost.
If the directory holding the pics I want to work on is called
practicephotos, should I declare something along the lines of filelist =
~/practicephotos/ or what?
regards, Richard
[code]
from PIL import Image
import os
for infile in filelist:
outfile - os.path.splitext(infile)[0] + ".jpg"
if infile != outfile:
try:
Image.open(infile).save(outfile)
except IOError:
print "cannot convert", infile
[/code]
--
"Treat all disasters as if they were trivialities but never treat a
triviality as if it were a disaster."
-- *Quentin Crisp<http://www.quotationspage.com/quotes/Quentin_Crisp>
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120804/6558c023/attachment-0001.html>
More information about the Tutor
mailing list