-1
import os
import sys, urllib2, urllib
import re
import time
from threading import Thread

class testit(Thread):
   def __init__ (self):
      Thread.__init__(self)
   def run(self):
        url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php'
        data = urllib.urlencode([('id',"btn_13_9_13"),  ('matchNo',"13")])
        req = urllib2.Request(url)
        fd = urllib2.urlopen(req, data)
<TAB>fd.close()
<TAB>"""while 1:
                data = fd.read(1024)
                if not len(data):
                        break
                sys.stdout.write(data)"""
        url2 = 'http://games.espnstar.asia/the-greatest-odi/post_perc.php'
        data2 = urllib.urlencode([('id',"btn_13_9_13"),  ('matchNo',"13")])
        req2 = urllib2.Request(url2)
        fd2 = urllib2.urlopen(req2, data2)
<TAB>#prints current votes
        while 1:
                data2 = fd2.read(1024)
                if not len(data2):
                        break
                sys.stdout.write(data2)
<TAB>fd2.close()
        print time.ctime()
        print " ending thread\n"

i=-1
while i<0:
   current = testit()
   time.sleep(0.001) #decrease this like 0.0001 for more loops
   current.start()

Hey can anybody help me finding out the error in the code Its saying inconsistent use of tabs an spaces in indentation

David Locke
  • 17,926
  • 9
  • 33
  • 53
user161004
  • 975
  • 3
  • 14
  • 23
  • 5
    Don't be a dick. This guy is a n00b, and tabs vs spaces is a legitimately confusing issue. They look exactly the same! – joeforker Sep 16 '09 at 17:52
  • @joeforker: (1) I'm trying to help him solve his problem. (2) Read the OP's comments on @Thomas Owens answer. (3) N00b or not, the question has already been asked on SO regarding Python. (4) It's covered in the Python tutorial. – S.Lott Sep 16 '09 at 18:02
  • Duplicate: http://stackoverflow.com/questions/1024435/howto-fix-python-indentation – S.Lott Sep 16 '09 at 18:04
  • Sure, 'please edit it for me' is pretty extreme. A pointer to the duplicate question is useful, but he probably doesn't know what \t means yet. – joeforker Sep 16 '09 at 19:04

2 Answers2

5

I edited your post to replace all the tabs with <TAB>. You need to delete the indentation on those lines and line it back up with spaces. Some editors can do that for you, but I don't know which editor you are using.

If you get serious about Python, you should reconfigure your editor to always insert 4 spaces when the tab key is pressed. You can also try changing the amount of indentation provided by the tab character or in some editors print a visible symbol for the tab character so you can see where the problem is.

joeforker
  • 40,459
  • 37
  • 151
  • 246
  • 2
    You're a kind soul. Now could you help the OP with vaccumming his office on Tuesday nights ;-) – mjv Sep 16 '09 at 17:25
4

Unfortunately, it looks like the code formatter here on Stack Overflow turns everything into spaces. But the error is quite self-explanatory. Python, unlike the curly-brace languages (like C, C++, and Java) uses indentation to mark blocks of code. The error means that a block is improperly indented.

Thomas Owens
  • 114,398
  • 98
  • 311
  • 431