473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

IndentationError: unexpected indent

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?
Jun 14 '07 #1
6 34294
You have possibly unvisible tab characters in your file.
Just copy your lines to the simple MS notepad and try again.

Wim Vogelaar, http://home.wanadoo.nl/w.h.vogelaar/
Jun 14 '07 #2
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.
Jun 14 '07 #3
"Wim Vogelaar" <wim.vogelaar at mc2world dot orgwrote:
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.

--
BOFH excuse #126:

it has Intel Inside

Jun 15 '07 #4
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/
Jun 16 '07 #5
How is he supposed to run MS notepad on X11? :)
I am saying MS notepad, but any software (running on Linux) showing you
clearly the tabs will help.

It would also be very convenient when python would deal with tabs in a human
friendly way.

Wim Vogelaar, http://home.wanadoo.nl/w.h.vogelaar/
Jun 16 '07 #6
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
Jun 17 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mr. Magoo | last post by:
Why does py_compile print IndentationError in a different format than SyntaxError? It makes it harder to parse the output in a non-python program. Sorry: IndentationError: ('unindent does not...
1
by: Rolf Kemper | last post by:
Dear Experts, I'm going to create an Excell spreadsheet xml. So far things work very well. But in case I add <Row> elements by a recursive template call it goes wrong. See the attached XSLT...
1
by: will | last post by:
All I am trying to pass a simple xml file using xmlspy : <?xml version="1.0" standalone="no"?> <inventory> <vehicle> <make>Chevy</make>
1
by: Vincent | last post by:
I noticed an irritating behaviour of the text-indent property and I wonder if I'm the only one to feel this way about it: it seems that text-indent applies even to floated elements. Although this...
1
by: Christopher P. Winter | last post by:
I'm seeing some unexpected behavior with Text-indent, as shown on this page: http://www.chris-winter.com/Digressions/HP_Kayak/My_Kayak.html I set up the following style rules for footnotes: ...
7
by: kagard | last post by:
Greetings: I'm brand new to Python and decided to write a syllogism solver for a class I'm taking. At the start of the program, I define a function that classifies the type of each statement in...
2
by: Chris Seidel | last post by:
Hi, I have a submit-element with a background-image of 16x16 px and the following style: background-image: url("ok.gif"); background-repeat: no-repeat; text-indent: 20 px; The problem is,...
3
by: brkseven | last post by:
Looking for help with this Contact Form. The error is on line 1, but that' doesn't mean a lot, I think. In fact, a php syntax check passed it, but I was hoping for an easy syntax error, it looks...
3
by: cwggenius | last post by:
Getting the following error. But I cannot figure out why. Could someone please alter my code and explain where I am going wrong? ./checkprocess2.py File "./checkprocess2.py", line 19 ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.