maker( pass to argument action at what we get back is reference to the generated nested function--the one created when the nested def runs if we now call what we got back from the outer functionf( ( pass to xn remembers * * we invoke the nested function--the one called action within maker in other wordswe're calling the nested function that maker created and passed back perhaps the most unusual part of thisthoughis that the nested function remembers integer the value of the variable in makereven though maker has returned and exited by the time we call action in effectn from the enclosing local scope is retained as state information attached to the generated actionwhich is why we get back its argument squared when it is later called just as importantif we now call the outer function againwe get back new nested function with different state information attached that iswe get the argument cubed instead of squared when calling the new functionbut the original still squares as beforeg maker( ( ( remembers remembers * * this works because each call to factory function like this gets its own set of state information in our casethe function we assign to name remembers and remembers because each has its own state information retained by the variable in maker this is somewhat advanced technique that you may not see very often in most codeand may be popular among programmers with backgrounds in functional programming languages on the other handenclosing scopes are often employed by the lambda function-creation expressions we'll expand on later in this -because they are expressionsthey are almost always nested within def for examplea lambda would serve in place of def in our exampledef maker( )return lambda xx * maker( ( lambda functions retain state too * again for more tangible example of closures at worksee the upcoming sidebar "why you will carecustomizing openon page it uses similar techniques to store information for later use in an enclosing scope scopes