point_to_managedDB = None
def _get_correct_DB_flag():
if ENV == "dev":
global point_to_managedDB
point_to_managedDB = os.environ.get("OIA_POINT_TO_MANAGED_DB_DEV")
elif ENV == "stg":
global point_to_managedDB
point_to_managedDB = os.environ.get("OIA_POINT_TO_MANAGED_DB_STG")
elif ENV == "prod":
global point_to_managedDB
point_to_managedDB = os.environ.get("OIA_POINT_TO_MANAGED_DB_PROD")
_get_correct_DB_flag()
Whats wrong in this code? Im getting :
File "/oia_application/scripts/database/env/sql_environments.py",
line 37
global point_to_managedDB
^
SyntaxError: name 'point_to_managedDB' is assigned to before global declaration
I know there are similar issue asked in SO but I whats wrong in my code I cant figure out. I've declared global inside the method only.
globaldeclaration at the top of the function definition, not in eachifblock