0

for the following code:

if __name__ == '__main__':
    min_version = (2,5)
    current_version = sys.version_info
if (current_version[0] > min_version[0] or
    current_version[0] == min_version[0] and
    current_version[1] >= min_version[1]):
else:
    print "Your python interpreter is too old. Please consider upgrading."
    config = ConfigParser.ConfigParser()
    config.read('.hg/settings.ini')
    user = config.get('user','name')
    password = config.get('user','password')
    resource_name = config.get('resource','name')
    server_url = config.get('jira','server')
    main()

i get error:

 else:
       ^
IndentationError: expected an indented block
kamal
  • 9,637
  • 30
  • 101
  • 168

2 Answers2

6

You don't have anything in the if side of your if statement. Your code skips directly to the else, while python was expecting a block (an "indented block", to be precise, which is what it is telling you)

At the very least, you need a block with just a 'pass' statement, like this:

if condition:
    pass
else:
    # do a lot of stuff here

In that case, though, if you really don't ever want to do anything in the if side, then it would be clearer to do this:

if not condition:
   # do all of your stuff here
Ian Clelland
  • 43,011
  • 8
  • 86
  • 87
2

The if must contain one or more statements, e.g.:

if (current_version[0] > min_version[0] or
    current_version[0] == min_version[0] and
    current_version[1] >= min_version[1]):
    pass # <-------------------------------------ADDED
else:
    # ...

The pass statement is a placeholder statement that does nothing.

istruble
  • 13,363
  • 2
  • 47
  • 52
NPE
  • 486,780
  • 108
  • 951
  • 1,012