IndentationError: unexpected indent

Laurent Pointal laurent.pointal at limsi.fr
Thu Jun 14 14:40:54 CEST 2007


desktop a écrit :
> I have this class:
> 
> class case(blop.case):
>   def __init__(self, n, a, b):
>     blop.case.__init__(self)
>     print 'Monty Python's Flying Circus has a ' within it...'
>     ...
>     ...
> 
> But I get an error when I run the .py script from shell saying:
> 
>     print 'Monty Python's Flying Circus has a ' within it...'
>     ^
> IndentationError: unexpected indent
> 
> I have tried to indent the print statement 8 blanks but that does not 
> help. Any hints?

You have also another error:

 >>> print 'Monty Python's Flying Circus has a ' within it...'
   File "<stdin>", line 1
     print 'Monty Python's Flying Circus has a ' within it...'
                         ^
SyntaxError: invalid syntax

Better:
 >>> print "Monty Python's Flying Circus has a ' within it..."
Monty Python's Flying Circus has a ' within it...



Note: for your indentation problem, try to use an editor allowing to 
display tab and spaces and then identify the problem location, or 
replace all tabs by 4 spaces and configure the editor to only use spaces.



More information about the Python-list mailing list