Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.05; 'error:': 0.07; '*is*': 0.09; 'here?': 0.09; 'skip:o 50': 0.09; 'spaces': 0.09; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'tabs': 0.16; 'wrote:': 0.18; 'input': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'refers': 0.24; 'script': 0.25; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'indentation': 0.31; 'file': 0.32; 'problem': 0.35; 'but': 0.35; 'consistent': 0.36; 'next': 0.36; 'level': 0.37; 'expected': 0.38; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'hope': 0.61; 'subject:there': 0.68 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Tue, 28 May 2013 09:55:52 -0600 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: IndentationError: expected an indented block but it's there References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369756559 news.xs4all.nl 15922 [2001:888:2000:d::a6]:54502 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46300 On 05/28/2013 09:32 AM, JackM wrote: > Having a problem getting a py script to execute. Got this error: > > File "/scripts/blockIPv4.py", line 19 > ip = line.split(';')[0] > ^ > IndentationError: expected an indented block > I'm perplexed because the code that the error refers to *is* indented: > with open('/var/www/html/mydomain.com/banlist.txt','r') as inFile: > for line in inFile.readlines(): > ip = line.split(';')[0] > output = os.popen( '/etc/sysconfig/iptables -A INPUT -s ' + ip > + ' -j REJECT' ) > logFile.write(ip+' - Has been blocked\n') > > > What am I missing here? Indentation has to be consistent. likely the for line is indented with spaces and the next line with a tab. You can use tabs and spaces, but you have to be consistent with how you use them. IE if level 1 is indented with spaces, then level 2 has to be indented with spaces up to level 1 as well. Hope that makes sense.