file kargs get('file'sys stdoutoutput 'first true for arg in argsoutput +('if first else sepstr(argfirst false file write(output endto test itimport this into another file or the interactive promptand use it like the print function here is test scripttestprint py (notice that the function must be called "print "because "printis reserved word in )from print import print print ( print ( sep=''print ( sep='print ( [ ]( ,)sep='print ( sep=''end=''print ( print (suppress separator various object types suppress newline add newline (or blank lineimport sys print ( sep='??'end=\ 'file=sys stderrredirect to file when this is run under xwe get the same results as ' print functionc:\codec:\python \python testprint py [ ( , ?? ?? although pointless in xthe results are identical when run there as usualthe generality of python' design allows us to prototype or develop concepts in the python language itself in this caseargument-matching tools are as flexible in python code as they are in python' internal implementation using keyword-only arguments it' interesting to notice that this example could be coded with python keywordonly argumentsdescribed earlier in this to automatically validate configuration arguments the following variantin the file print _alt pyillustrates#!python "use only keyword-only argsimport sys def print (*argssep='end='\ 'file=sys stdout)output ' arguments