more typicallylambdas are used to provide an indirection layer that passes along extra data to callback handler ( omit pack and mainloop calls in the following snippets for simplicity)def handler(ab)use and would normally be called with no args button(text='ni'command=(lambdahandler( 'spam'))lambda adds arguments although tkinter invokes command callbacks with no argumentssuch lambda can be used to provide an indirect anonymous function that wraps the real handler call and passes along information that existed when the gui was first constructed the call to the real handler isin effectdeferredso we can add the extra arguments it requires herethe value of global variable and string 'spamwill be passed to arguments and beven though tkinter itself runs callbacks with no arguments the net effect is that the lambda serves to map no-argument function call to one with arguments supplied by the lambda if lambda syntax confuses youremember that lambda expression such as the one in the preceding code can usually be coded as simple def statement insteadnested or otherwise in the following codethe second function does exactly the same work as the prior lambda--by referencing it in the button creation callit effectively defers invocation of the actual callback handler so that extra arguments can be passeddef handler(ab)use and def func()handler( 'spam'would normally be called with no args indirection layer to add arguments button(text='ni'command=functo make the need for deferrals more obviousnotice what happens if you code handler call in the button creation call itself without lambda or other intermediate function-the callback runs immediately when the button is creatednot when it is later clicked that' why we need to wrap the call in an intermediate function to defer its invocationdef handler(name)print(namebutton(command=handler('spam')badruns the callback nowusing either lambda or callable reference serves to defer callback invocation until the event later occurs for exampleusing lambda to pass extra data with an inline function definition that defers the calldef handler(name)print(name graphical user interfaces