indentation error

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Feb 2008
Posts: 21
Reputation: johndoe444 is an unknown quantity at this point 
Solved Threads: 0
johndoe444 johndoe444 is offline Offline
Newbie Poster

indentation error

 
0
  #1
Jul 1st, 2009
Hi,
This is the existing code:

  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

  1. chartUrl = baseChartUrl+c

by putting the cursor to the end of the

  1. for c in chartNames:

and pressing an enter I get compile error.

what's happening here?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 20
Reputation: rupeshpradhan is an unknown quantity at this point 
Solved Threads: 2
rupeshpradhan rupeshpradhan is offline Offline
Newbie Poster

Re: indentation error

 
0
  #2
Jul 1st, 2009
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:
  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
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,401
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 128
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: indentation error

 
1
  #3
Jul 1st, 2009
what editor do you use?
Get ulipad
http://code.google.com/p/ulipad/
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,045
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 294
woooee woooee is offline Offline
Veteran Poster

Re: indentation error

 
0
  #4
Jul 1st, 2009
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.
  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.
Linux counter #99383
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,062
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 267
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: indentation error

 
0
  #5
Jul 1st, 2009
Originally Posted by evstevemd View Post
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?!
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC