Question about code writing '% i, callback'
Terry Reedy
tjreedy at udel.edu
Mon Nov 30 12:36:56 EST 2015
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
More information about the Python-list
mailing list