Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '16,': 0.03; 'pil': 0.09; 'statements': 0.09; 'try:': 0.09; 'subject:How': 0.10; 'block.': 0.16; 'errors:': 0.16; 'filelist': 0.16; 'ioerror:': 0.16; 'iterates': 0.16; 'subject:those': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'seems': 0.21; 'example': 0.22; 'import': 0.22; 'print': 0.22; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'getting': 0.31; 'indentation': 0.31; 'probably': 0.32; 'except': 0.35; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'should': 0.36; 'level': 0.37; 'expected': 0.38; 'follows:': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'called': 0.40; 'skip:o 30': 0.61; 'within': 0.65; '--->': 0.84; 'confusing': 0.84; 'presumably': 0.84; 'try.': 0.91; 'walking': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=qSbB5l8qQiXjrLXNUfNEfNRYUFrwD+VYEuDeA6RDtqA=; b=fukYocMPLXZQSBY+OzV6dYgkF2ZcO6jS8MsUst8P7PVI8ddBRvmNWsxsLgLxZRRkqd E0JlqtjTAUe/h5u6CJ09OWQfeRxj/V83KZ49y3F/kwWf0HxTqr7N7gusinxxjMkVAPLM /VHV/PK+Rev5AU6s05cR6reVqlDpJgK+flq3bQOzM1PgYqVWH6SgrCPQnphHPm1bBIQZ aI/ZxJmfmENoU6cPMb9uoWV3IuqcLGwKqzTuvxp1iSHWAEMflU8rZMEOaCymsMdFloFj WkSIErAmT9I2tdAXSS7/fwaGvycelpOLiaepR52jxaKIbIl0zan+UpWW1iaiVQf45fl7 nFWA== X-Received: by 10.69.26.197 with SMTP id ja5mr25142692pbd.111.1416175180969; Sun, 16 Nov 2014 13:59:40 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Sun, 16 Nov 2014 14:59:00 -0700 Subject: Re: How to fix those errors? To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416175191 news.xs4all.nl 2932 [2001:888:2000:d::a6]:60479 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80916 On Sun, Nov 16, 2014 at 2:32 PM, Abdul Abdul 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.