943,836 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 1073
  • Python RSS
Jul 1st, 2009
0

indentation error

Expand Post »
Hi,
This is the existing code:

Python Syntax (Toggle Plain Text)
  1. for c in chartNames:
  2. chartUrl = baseChartUrl+c
  3. hd = extractChart(chartUrl)
  4.  
  5. writeChart(hd,c)
  6.  
  7. for key in hd:
  8. if key in chart:
  9. chart[key].append(c)
  10. else:
  11. chart[key] = [c]

when i wanted to insert a line before

Python Syntax (Toggle Plain Text)
  1. chartUrl = baseChartUrl+c

by putting the cursor to the end of the

Python Syntax (Toggle Plain Text)
  1. for c in chartNames:

and pressing an enter I get compile error.

what's happening here?
Similar Threads
Reputation Points: 11
Solved Threads: 0
Posting Whiz in Training
johndoe444 is offline Offline
214 posts
since Feb 2008
Jul 1st, 2009
0

Re: indentation error

1. Can you please make the indentation level to 4 spaces.

2. Please use 'code=python' surrounded by square '[ ]' bracets so that it will be correctly cololur coded and end with '\code' enclosed in the same square brackets. Click on the link below for mode details on code tags
http://www.daniweb.com/forums/misc-e...=400&width=680

OR you can click the link on the right side in the box below called '
Help with Code Tags'

This is what your code should look like:
python Syntax (Toggle Plain Text)
  1. for c in chartNames:
  2. chartUrl = baseChartUrl+c
  3. hd = extractChart(chartUrl)
  4.  
  5. writeChart(hd,c)
  6.  
  7. for key in hd:
  8. if key in chart:
  9. chart[key].append(c)
  10. else:
  11. chart[key] = [c]

3. Please provide hard coded values and to the list / tuple / dictionary & variables and function so that it is executable and gives an output or atleast a traceback
Reputation Points: 10
Solved Threads: 2
Newbie Poster
rupeshpradhan is offline Offline
20 posts
since Oct 2004
Jul 1st, 2009
1

Re: indentation error

what editor do you use?
Get ulipad
http://code.google.com/p/ulipad/
Reputation Points: 462
Solved Threads: 392
Senior Poster
evstevemd is offline Offline
3,681 posts
since Jun 2007
Jul 1st, 2009
0

Re: indentation error

Quote ...
by putting the cursor to the end of the
for c in chartNames:
and pressing an enter I get compile error.
"I get a compile error" is too vague for anyone to figure out. It is probably that the blank line is not indented at the same level as the other lines and your editor does not like that (which is overly picky, but at the discretion of whoever wrote the editor), but as I said it is impossible to decipher without the line number of the error and what it is. Use try/except, especially when testing.
Python Syntax (Toggle Plain Text)
  1. try:
  2. for c in chartNames:
  3. chartUrl = baseChartUrl+c
  4. hd = extractChart(chartUrl)
  5.  
  6. writeChart(hd,c)
  7.  
  8. for key in hd:
  9. if key in chart:
  10. chart[key].append(c)
  11. else:
  12. chart[key] = [c]
  13. except:
  14. import traceback
  15. traceback.print_exc()
  16. raise
Last edited by woooee; Jul 1st, 2009 at 2:09 pm.
Reputation Points: 741
Solved Threads: 692
Nearly a Posting Maven
woooee is offline Offline
2,305 posts
since Dec 2006
Jul 1st, 2009
0

Re: indentation error

Click to Expand / Collapse  Quote originally posted by evstevemd ...
what editor do you use?
Get ulipad
http://code.google.com/p/ulipad/
How long have you known about this?
And why haven't you told us until now?!
Reputation Points: 355
Solved Threads: 292
Veteran Poster
jlm699 is offline Offline
1,102 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: A little help
Next Thread in Python Forum Timeline: String Conversion in Python





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC