Question about code writing '% i, callback'

fl rxjwg98 at gmail.com
Mon Nov 30 11:44:05 EST 2015


Hi,

I come across the following code snippet.





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




The content inside parenthesis in last line is strange to me. 

"button %s" % i, callback


That is, the writing looks like recognized as three items when I try with a
class definition (it can run with this):

class buibutton():
    print 'sd'
    def __nonzero__(self):
       return False
       
    def Button(str, ii, callbackk):
        
        return


Could you explain it to me?

The link is here:

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

Thanks,



More information about the Python-list mailing list