functions and functional programming executesit calls urlopen(urlwith the value of url that was originally supplied to page(with little inspectionyou can view the contents of variables that are carried along in closure for examplepython _closure_ (,python _closure_ [ cell_contents jython _closure_ [ cell_contents closure can be highly efficient way to preserve state across series of function calls for exampleconsider this code that runs simple counterdef countdown( )def next()nonlocal - return return next example use next countdown( while truev next(if not vbreak get the next value in this codea closure is being used to store the internal counter value the inner function next(updates and returns the previous value of this counter variable each time it is called programmers not familiar with closures might be inclined to implement similar functionality using class such as thisclass countdown(object)def _init_ (self, )self def next(self) self self - return example use countdown( while truev next(if not vbreak get the next value howeverif you increase the starting value of the countdown and perform simple timing benchmarkyou will find that that the version using closures runs much faster (almost speedup when tested on the author' machinethe fact that closures capture the environment of inner functions also make them useful for applications where you want to wrap existing functions in order to add extra capabilities this is described next lib fl ff