On 11/30/2015 11:44 AM, fl wrote:

I come across the following code snippet.

for i in range(10):
     def callback():
         print "clicked button", i
     UI.Button("button %s" % i, callback)

http://effbot.org/zone/default-values.htm

Note that the above is an intentional example of common buggy code. It is followed by a version that works, with 'i=i' added to the callback header.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to