[Tutor] "expected an indented block" (see attached)

Alex Hall mehgcap at gmail.com
Thu Jul 22 15:52:53 CEST 2010

On 7/22/10, Evert Rol <evert.rol at gmail.com> wrote:
>> Attached is a file. When I run the program it is part of, I get an
>> error that says:
>> line 62: IndentationError: expected an indented block.
> This function:
>  def fromString(self, str):
>   #creates a Craft object from the string
> #end class Craft
> Is completely empty (the comment lines are discarded). So Python expects any
> next piece of code to be inside this method (and thus indented).
Oh, I did not realize it threw out comments. That explains it, then!
> If you want an empty function, use 'pass' instead.
> (also consider using four spaces for indentation, which I've also found much
> clearer. Have a read through PEP 8; has a lot of interesting tidbits.
> And an editor with a good Python mode is very handy, because that would have
> almost automatically indented the next piece of code, 'class
> Battleship(Craft)', which would have indicated something went awry before
> that line).
The only problem is that I have not found an accessible editor that
will do this.
>> I can see nothing wrong with the indentation, though. This is part of
>> my Battleship game, defining all the different ships and aircraft the
>> user can have, as well as the special weapons methods for each ship.
>> If anyone can spot the problem, it would be great. I know I only
>> indent one space, instead of the normal four, but I use a screen
>> reader and it is a lot easier and faster to do it this way. If a
>> version of Python based on braces instead of indents were released, my
>> world would be so much better!

Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap

More information about the Tutor mailing list