Skip to content Skip to sidebar Skip to footer

Python IndentationError: Expected An Indented Block

I am trying to fix this script. I keep receiving an error 11:14:22 # ./datasource_config.py File './datasource_config.py', line 11 global AdminConfig ^

Solution 1:

You have no indentation in your Python code!

def datasource(cluster,user,password,url,env,jdbc_driver,timeOut,maxConn,minConn,reapTime,unusdTimeout,agedTimeout):
    #Declare global variables 
    global    AdminConfig 
    global    AdminControl

Fixing this, there will be others. The next one to fix is:

if len(Serverid) == 0:
    print "Cluster doesnot exists "    
else:    
    print "Cluster exist:"+ cluster

and so on.


Solution 2:

Python uses indentation in the same way other languages use curly braces ({}) to denote code blocks

Any line that ends with a colon (def, if, else, for, try, except, etc), needs to be followed by indented lines (generally 4 spaces) in order for the interpreter to know what code is part of that "block"


Post a Comment for "Python IndentationError: Expected An Indented Block"