Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46300
| 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 | <torriem@gmail.com> |
| 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 <torriem@gmail.com> |
| 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 | <V54pt.161708$Zp1.55817@en-nntp-15.dc1.easynews.com> |
| In-Reply-To | <V54pt.161708$Zp1.55817@en-nntp-15.dc1.easynews.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2301.1369756559.3114.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
IndentationError: expected an indented block but it's there JackM <notreal@earthlink.net> - 2013-05-28 11:32 -0400 Re: IndentationError: expected an indented block but it's there Michael Torrie <torriem@gmail.com> - 2013-05-28 09:55 -0600 Re: IndentationError: expected an indented block but it's there Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-28 16:01 +0000 Re: IndentationError: expected an indented block but it's there Peter Otten <__peter__@web.de> - 2013-05-28 18:19 +0200 Re: IndentationError: expected an indented block but it's there Chris Angelico <rosuav@gmail.com> - 2013-05-29 02:31 +1000 Re: IndentationError: expected an indented block but it's there Peter Otten <__peter__@web.de> - 2013-05-28 18:53 +0200 Re: IndentationError: expected an indented block but it's there Chris Angelico <rosuav@gmail.com> - 2013-05-29 17:59 +1000
csiph-web