row and each character in the string represents button lambdas are used to save extra callback data for each button the callback functions retain the button' character and the linked text entry variable so that the character can be added to the end of the entry widget' current string on press notice how we must pass in the loop variable as default argument to some lambdas in this code recall from how references within lambda (or nested defto names in an enclosing scope are evaluated when the nested function is callednot when it is created when the generated function is calledenclosing scope references inside the lambda reflect their latest setting in the enclosing scopewhich is not necessarily the values they held when the lambda expression ran by contrastdefaults are evaluated at function creation time instead and so can remember the current values of loop variables without the defaultseach button would reflect the last iteration of the loop lesson embedding beats parsers the calculator uses eval and exec to call python' parser and interpreter at runtime instead of analyzing and evaluating expressions manually in effectthe calculator runs embedded python code from python program this works because python' development environment (the parser and bytecode compileris always part of systems that use python because there is no difference between the development and the delivery environmentspython' parser can be used by python programs the net effect here is that the entire expression evaluator has been replaced with single call to eval or exec in broader termsthis is powerful technique to rememberthe python language itself can replace many smallcustom languages besides saving development timeclients have to learn just one languageone that' potentially simple enough for end-user coding furthermorepython can take on the flavor of any application if language interface requires application-specific extensionsjust add python classesor export an api for use in embedded python code as extension by evaluating python code that uses application-specific extensionscustom parsers become almost completely unnecessary there' also critical added benefit to this approachembedded python code has access to all the tools and features of powerfulfull-blown programming language it can use listsfunctionsclassesexternal modulesand even larger python tools like tkinter guisshelve storagemultiple threadsnetwork socketsand web page fetches you' probably spend years trying to provide similar functionality in custom language parser just ask guido running code strings this module implements gui calculator in some lines of code (counting comments and blank linesbut truthfullyit "cheats expression evaluation is delegated entirely to python in factthe built-in eval and exec tools do most of the work here text and language