IndentationError: expected an indented block but it's there

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue May 28 12:01:14 EDT 2013


On Tue, 28 May 2013 11:32:06 -0400, 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:

Whenever you get perplexing indentation errors, suspect an inconsistency 
due to mixed tabs and spaces.

Tabs good. Spaces good. Tabs and spaces together, bad.

You can run the tabnanny module over your source code:

python -m tabnanny  <file-or-directory>


to convert indentation to all spaces.


-- 
Steven



More information about the Python-list mailing list