appendix python example py -import configparser +import configparser -for in xrange( )print * +for in range( )print( *idef spam( )if not has_key("spam")if "spamnot in dd["spam"load_spam(return ["spam"refactoringtoolfiles that need to be modifiedrefactoringtoolexample py as output to will identify parts of the program that it considers to be problematic and that might need to be changed these are shown as context-diffs in the output although we have used to on single fileif you give it the name of directoryit recursively looks for all python files contained in the directory structure and generates report for everything by default to does not actually fix any of the source code it scans--it merely reports parts of the code that might need to be changed challenge faced by to is that it often only has incomplete information for exampleconsider the spam(function in the example code this function calls method has_key(for dictionarieshas_key(has been removed in favor of the in operator to reports this changebut without more informationit is not clear if spam(is actually manipulating dictionary or not it might be the case that is some other kind of object ( database perhapsthat happens to provide has_key(methodbut where using the in operator would fail another problematic area for to is in the handling of byte strings and unicode given that python would automatically promote byte strings to unicodeit is somewhat common to see code that carelessly mixes the two string types together unfortunately to is unable to sort all of this out this is one reason why it' important to have good unit test coverage of courseall of this depends on the application as an option to can be instructed to fix selected incompatibilities firsta list of "fixerscan be obtained by typing to - for example to - available transformations for the - /--fix optionapply basestring buffer callable xrange xreadlines zip using names from this listyou can see what selected fix would actually change by simply typing " to - fixname filenameif you want to apply multiple fixesjust specify each one with separate - option if you actually want to apply the fix to source fileadd the - option as in to - fixname - filename here is an examplef lib fl ff