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!

Answers


One solution is: to change the line listOfSteps[i] += ... to:

listOfSteps[i] = listOfSteps[i] + ' AvgTime:' + tmpstr + 'sec.;'

Need Your Help

Video view android and low api levels

android api android-videoview

my video plays on high api level phones its an mp4 format small clip

How do I make table cells fit the size of contained images?

xcode swift uitableview uiimageview xcode6

I'm trying to figure out how to make a table of images with varying sizes. Where the images get resized to fit the width of the device, and the cells fit the height of the image. Currently the imag...