Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80916 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2014-11-16 14:59 -0700 |
| Last post | 2014-11-16 14:59 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to fix those errors? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-16 14:59 -0700
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2014-11-16 14:59 -0700 |
| Subject | Re: How to fix those errors? |
| Message-ID | <mailman.15912.1416175191.18130.python-list@python.org> |
On Sun, Nov 16, 2014 at 2:32 PM, Abdul Abdul <abdul.sw84@gmail.com> wrote: > Hello, > > I'm walking through an example that goes as follows: > > from PIL import Image > import os > > for inputfile in filelist > outputfile = os.path.splitext(inputfile)[0]+".jpg" > if inputfile != outputfile: > try: > Image.open(inputfile).save(outputfile) > except IOError: > print "unable to convert ", inputfile > > I'm writing that in "Pycharm", and getting the following errors: > > * filelist ---> Unresolved reference 'filelist' Your for loop iterates over a variable called filelist, but you never define it. > * IOError: Statement seems to have no effect > > * The last 'filelist' ---> 'except' or 'finally' expected The indentation of your try and except statements don't appear to match, which is probably confusing it. The except should be at the same indentation level as the try. Also, the for should presumably be at the same indentation level as the imports, as it's not contained within a block.
Back to top | Article view | comp.lang.python
csiph-web