I'm trying to build a tkinter GUI, and I'm having a Python programming logic issue. My problem is the following: I'm creating a bunch of objects in the following way:
class Aplication:
def createObjects(self):
objects = []
for i in range(10):
obj = Object(command = lambda: self.myFunction(i))
objects.append(obj)
def myFunction(self, i):
print(i)
And when executing each object's command I expected the result:
0
1
2
3
4
5
6
7
8
9
But instead I'm getting:
9
9
9
9
9
9
9
9
9
9
I simplified my code so that anyone who knows Python logic can help me. Appreciate any help in advance.