testingdebuggingprofilingand tuning by defaultsplitting is performed on whitespacebut different delimiter can be selected with the delimiter keyword argumentsplit('goog, , ',delimiter=','['goog'' '' '""fields line split(delimiterif typesfields ty(valfor ty,val in zip(types,fieldsreturn fields common problem with writing documentation is keeping the documentation synchronized with the actual implementation of function for examplea programmer might modify function but forget to update the documentation to address this problemuse the doctest module doctest collects documentation stringsscans them for interactive sessionsand executes them as series of tests to use doctestyou typically create separate module for testing for exampleif the previous function is in file splitter pyyou would create file testsplitter py for testingas followstestsplitter py import splitter import doctest nfailntests doctest testmod(splitterin this codethe call to doctest testmod(moduleruns tests on the specified module and returns the number of failures and total number of tests executed no output is produced if all of the tests pass otherwiseyou will get failure report that shows the difference between the expected and received output if you want to see verbose output of the testsyou can use testmod(moduleverbose=trueas an alternative to creating separate testing filelibrary modules can test themselves by including code such as this at the end of the fileif _name_ =' _main_ 'test myself import doctest doctest testmod(with this codedocumentation tests will run if the file is run as the main program to the interpreter otherwisethe tests are ignored if the file is loaded with import doctest expects the output of functions to literally match the exact output you get in the interactive interpreter as resultit is quite sensitive to issues of white space and numerical precision for exampleconsider this functiondef half( )"""halves for examplehalf( ""return / lib fl ff