advanced programming techniques small yet useful examples and is well worth reading (note also that couple of new functions were added to the itertools module with python partial function application |partial function application is the creation of function from an existing function and some arguments to produce new function that does what the original function didbut with some arguments fixed so that callers don' have to pass them here' very simple exampleenumerate functools partial(enumeratestart= for linoline in enumerate (lines)process_line(ilinethe first line creates new functionenumerate ()that wraps the given function (enumerate()and keyword argument (start= so that when enumerate (is called it calls the original function with the fixed argument--and with any other arguments that are given at the time it is calledin this case lines here we have used the enumerate (function to provide conventional line counting starting from line using partial function application can simplify our codeespecially when we want to call the same functions with the same arguments again and again for exampleinstead of specifying the mode and encoding arguments every time we call open(to process utf- encoded text fileswe could create couple of functions with these arguments fixedreader functools partial(openmode="rt"encoding="utf "writer functools partial(openmode="wt"encoding="utf "now we can open text files for reading by calling reader(filenameand for writing by calling writer(filenameone very common use case for partial function application is in gui (graphical user interfaceprogramming (covered in )where it is often convenient to have one particular function called when any one of set of buttons is pressed for exampleloadbutton tkinter button(frametext="load"command=functools partial(doaction"load")savebutton tkinter button(frametext="save"command=functools partial(doaction"save")this example uses the tkinter gui library that comes as standard with python the tkinter button class is used for buttons--here we have created twoboth contained inside the same frameand each with text that indicates its purpose each button' command argument is set to the function that tkinter