IndentationError: unexpected indent

D

desktop

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?
 
L

Laurent Pointal

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

Better: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.
 
B

Bjoern Schliessmann

Wim Vogelaar said:
You have possibly unvisible tab characters in your file.
Just copy your lines to the simple MS notepad and try again.

How is he supposed to run MS notepad on X11? :)

Regards,


Björn

P.S.: YES, I know there is wine.
 
W

Wim Vogelaar

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.

It would be very helpful when Python would warn you when there are tabs in
your source.

So instead of only saying: "IndentationError: unexpected indent"
there could be an additional message saying: "there are tab characters in
that line, please remove them".

Wim Vogelaar, http://home.wanadoo.nl/w.h.vogelaar/
 
D

Dave Borne

It would be very helpful when Python would warn you when there are tabs in
your source.

invoke python with the -t option for warnings about tabs or -tt for errors.

-Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top