Home > Back-end >  Python getting local-variable-data-referenced-before-assignment error
Python getting local-variable-data-referenced-before-assignment error

Time:09-28

I am trying the following code wherein I want to use the variables declared outside the try catch also. But I am getting the local variable 'data_summary' referenced before the assignment error.

Following is my code.

data_summary, spdj_count, mstar_count, fs_count, dataframe_ricToMsarId, ricMissingPerformanceIds, dataframe_total_cases_count, dataframe_soi1_case_count, dataframe_soi_2_case_count, dataframe_soi_3_case_count, totalperfIdBoB, dataframe_treasury_check, treasuryEmailSummary, dataframe_fs_mapping_error, fsMissingPerformanceIds, dataframe_total_cases_count, dataframe_soi1_case_count, dataframe_soi_2_case_count, dataframe_soi_3_case_count, totalBoBperfIds

    try:
        data_summary, spdj_count, msar_count, fs_count = app.compare_floats(env, running_locally, region)
    except Exception as exp:
        print("Error while executing Report-- execute_compare_price - CE_API_Weekly -- Message -- "   str(exp))
    try:
        dataframe_ricToMstarId, ricMissingPerformanceIds, dataframe_total_cases_count, dataframe_soi1_case_count, dataframe_soi_2_case_count, dataframe_soi_3_case_count, totalperfIdBoB = app.getMissingRICPerformanceIDsReportDetails(
            env, running_locally, region)
    except Exception as exp:
        print("Error while executing Report-- execute_compare_price - CE_API_Weekly -- Message -- "   str(exp))
    try:
        dataframe_treasury_check, treasuryEmailSummary = app.getTreasuryDetails(env,
                                                                                running_locally,
                                                                                region)
    except Exception as exp:
        print("Error while executing Report-- execute_compare_price - CE_API_Weekly -- Message -- "   str(exp))
    try:
        dataframe_fs_mapping_error, fsMissingPerformanceIds, dataframe_total_cases_count, dataframe_soi1_case_count, dataframe_soi_2_case_count, dataframe_soi_3_case_count, totalBoBperfIds = app.getFactsetMappingErrorReportDetails(
            env, running_locally, region)
    except Exception as exp:
        print("Error while executing Report-- execute_compare_price - CE_API_Weekly -- Message -- "   str(exp))
        if dataframe_treasury_check > 0 or (ricMissingPerformanceIds > 0 and dataframe_ricToMstarId) > 0 or (
                fsMissingPerformanceIds > 0 and dataframe_fs_mapping_error) or (
                spdj_count > 0 or mstar_count > 0 or fs_count > 0) > 0:

            ricToMstarMappingEmailSummary = reporting.printRICMissingPerformanceIDReportEmailSummary(
                dataframe_total_cases_count,
                dataframe_soi1_case_count,
                dataframe_soi_2_case_count,
                dataframe_soi_3_case_count,

Can someone help?

CodePudding user response:

In first line you are telling interpreter to use variables that are not defined anywhere above.

Remove first line.

  • Related