you can change the destination of the print statement by adding the special >>file modifier followed by commawhere file is file object that allows writes here' an examplef open("output"," "print >> "hello worldf close(the print(function one of the most significant changes in python is that print is turned into function in python it is also possible to use print as function if you include the statement from _future_ import print_function in each module where used the print(function works almost exactly the same as the print statement described in the previous section to print series of values separated by spacesjust supply them all to print(like thisprint("the values are"xyzto suppress or change the line endinguse the end=ending keyword argument for exampleprint("the values are"xyzend=''suppress the newline to redirect the output to fileuse the file=outfile keyword argument for exampleprint("the values are"xyzfile=fredirect to file object to change the separator character between itemsuse the sep=sepchr keyword argument for exampleprint("the values are"xyzsep=','put commas between the values variable interpolation in text output common problem when generating output is that of producing large text fragments containing embedded variable substitutions many scripting languages such as perl and php allow variables to be inserted into strings using dollar-variable substitutions (that is$name$addressand so onpython provides no direct equivalent of this featurebut it can be emulated using formatted / combined with triple-quoted strings for exampleyou could write short form letterfilling in namean item nameand an amountas shown in the following examplenotetrailing slash right after ""prevents blank line from appearing as the first line form """dear %(name)sf lib fl ff