0

I don't exactly know if is it a bug, or my editor error, but at specific line, it always throw an 'IndentationError: unindent ...'
My code is:

def tokType(token):
    if type(token) is str:
        if ":" in token:
            out = ""
            for c in token:
                if c == ":":
                    break
                out += c
            return out
        else:
            return None
    elif type(token) is list:
        for i, t in enumerate(token):
            if i != 0 and tokType(t) != tokType(token[i-1]):
                return "multi"
        return tokType(token[0])
    else:
        raise TypeError("Unsupported type {0}, expecting List or String!".format(type(token)))

Why am I getting this error??

R.O.S.S
  • 605
  • 5
  • 18
  • What line does it say? –  Mar 28 '15 at 17:11
  • I copy-pasted your code and it worked on my system – XrXr Mar 28 '15 at 17:12
  • to Nathan Geist: At any line I paste after `else: return None`. – R.O.S.S Mar 28 '15 at 17:14
  • to XrXrXr: I have OS X 10.10.3 – R.O.S.S Mar 28 '15 at 17:14
  • If it's not at the same indentation level as the "return None" or after the next "elif" there will be an indentation error thrown, but with the code you provided, it runs fine. –  Mar 28 '15 at 17:15
  • I see, it's the editor error... I use the Atom and it seems to change between spaces and tabs... But why? My file (as I found) is a mixture of spaces and tabs. – R.O.S.S Mar 28 '15 at 17:27
  • You can set editors to use a certain amount of spaces in a tab, me for instance, I generally use 2 for python, 4 for java. I actually made a python program in one of my classes to correct indentation. I'm going to try to put your code through it and see the result. –  Mar 28 '15 at 17:33
  • possible duplicate of [IndentationError: unindent does not match any outer indentation level](http://stackoverflow.com/questions/492387/indentationerror-unindent-does-not-match-any-outer-indentation-level) – Anthony Geoghegan Mar 28 '15 at 21:01

1 Answers1

0

It was editor fault. It started to write tabs instead of spaces. I just Found-Replaced the tabs with spaces and checked my Settings.

R.O.S.S
  • 605
  • 5
  • 18