"UnboundLocalError: …" after creating objects within nested control blocks

Advertisements I am writing a Python module which removes the background from animated GIF images. My problem function takes a directory path string and a URL string as input. The function uses an IF statement to pick either the URL or the path, based on if the URL is empty ("") or not. Pseudo-code is… Read More "UnboundLocalError: …" after creating objects within nested control blocks

Changing local variable using recursion

Advertisements I am using a recursive function implemented in a python class. Am I right that the local variable (passed through the methods attributes) isn’t changing through a recursive change? I have the following tree: example tree My current method is the following: def readSequence(self, linkTable, partTable, seq, element): #clearFlags returns an array of objects… Read More Changing local variable using recursion

using same variable that is created in function into another function

Advertisements I want to use ‘number’ variable that was created out of the function and use it in couple functions and also give it an initial value 0, but it gives "local variable ‘number’ referenced before assignment" error at the last line of code.How could I fix it?Thanks in advance. lst_img=[img0,img1,img2,img3,img4] number=0 def go_forward(): global… Read More using same variable that is created in function into another function