473,719 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IndentationErro r: unexpected indent

I have this class:

class case(blop.case) :
def __init__(self, n, a, b):
blop.case.__ini t__(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...'
^
IndentationErro r: unexpected indent

I have tried to indent the print statement 8 blanks but that does not
help. Any hints?
Jun 14 '07 #1
6 34344
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.__ini t__(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...'
^
IndentationErro r: 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: "IndentationErr or: 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
1608
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 match any outer indentation level', ('foo.py', 19, 17, '\t\t\t return 0.0 \n')) instead of File "foo.py", line 19
1
3277
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 and the result. Last 30 lines of the xslt may be the most interesting ones. I'm processing it with XMLSPY. Regardless of the xslt processor (ALTOVA / MSXML4 ) I get the same result.
1
2839
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
5868
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 is probably correct according to the specification (text-indent is inherited), don't you think it makes no sense to apply text-indent to such elements ? Here is an example: I have a paragraph, starting with a clickable image, that's followed by...
1
1853
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: DIV.FootRule { Border-bottom: 1px Solid Gray; Margin-bottom: 2px; Text-align: Left; Width: 20% }
7
3559
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 the syllogism. Python tells me that it is expecting an indented block at the s in "some". I can see what I'm doing wrong. Here's the code: def class_stmt(q,c): """
2
3571
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, that text-indent is ignored. When I supply the style to a
3
5192
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 more complicated now. Anyway, here's the error: "Parse error: syntax error, unexpected T_VARIABLE in /home/xxx/public_html/yyy/zzz/contactengine.php on line 1" It's a contact form from css-tricks, when I submit that's what I get.
3
4482
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 else: ^ IndentationError: expected an indented block #!/usr/bin/python
0
8828
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8725
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9208
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6658
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5971
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3185
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2124
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.