UnboundLocalError when using str() in python
I experience a strange issue!
In my python code I have the following line:
tmpstr = str(tx_execution) listOfSteps[i] += ' AvgTime:' + tmpstr + 'sec.;'
But on execution i got:
File "/storage/share/test_main.py", line xxxx, in runStep tmpstr = str(tx_execution) UnboundLocalError: local variable 'str' referenced before assignment
Any clue what could cause this?
I am using in other parts of my pyhton code the command str(), which is working fine!
Thanks for your time!
One solution is: to change the line listOfSteps[i] += ... to:
listOfSteps[i] = listOfSteps[i] + ' AvgTime:' + tmpstr + 'sec.;'