Jan-26-2020, 10:48 PM
Hi all,
I have a python script that basically works as follows:
Function A is still being called, as I'm getting function A error
Function B really only does return a string - so it doesn't adjust any variable that function A might use
WHen I put the return statement directly into the elif statement as an append, everything works perfectly.
Any help or tips on where to look would be appreciated! :)
I have a python script that basically works as follows:
Items = pd.Dafaframe(some excel sheet) def FunctionA(items): try: """Does some stuff""" return(answer) except: return("Fuction A error") Answers = [] for item in Items: if item["Attribute"] == "A": Answers.append(FunctionA(items)) elif item["Attribute"] == "B": Answers.append("Attirubte type is B") else: return("Error")This works perfectly fine and works exactly as expected. The "Function A error" is never returned (as it shouldn't be, it's purely there to catch any unexpected exception. If I choose to develop a Function to Handle Type 4, for instance changing my code to the following, every single time Function A is called it returns "Function A error":
Items = pd.Dafaframe(some excel sheet) def FunctionA(item): try: """Does some stuff""" return(answer) except: return("Fuction A error") def FunctionB(item): return("Attribute type is B") Answers = [] for item in Items: if item["Attribute"] == "A": Answers.append(FunctionA(items)) elif item["Attribute"] == "B": Answers.append(FunctionB(item)) else: return("Error")Any thoughts on why this might be the case? I'm very confused for the following reasons:
Function A is still being called, as I'm getting function A error
Function B really only does return a string - so it doesn't adjust any variable that function A might use
WHen I put the return statement directly into the elif statement as an append, everything works perfectly.
Any help or tips on where to look would be appreciated! :)