--- .\variation_algorithms.py	(original)
+++ .\variation_algorithms.py	(refactored)
@@ -13,7 +13,7 @@
 # calibre Python 3 compatibility.
 import six
 from six import text_type as unicode
-from six import string_types as basestring
+from six import string_types as str
 
 from calibre import prints
 from calibre.constants import DEBUG
@@ -89,7 +89,7 @@
             result = self.fn(item_text)
             # Have to cope with functions returning 1 or 2 results since
             # author functions do the reverse hash too
-            if isinstance(result, basestring):
+            if isinstance(result, str):
                 candidates_map[result].add(item_id)
             else:
                 hash1 = result[0]
@@ -162,10 +162,10 @@
     alg = VariationAlgorithm(db())
     dm, cm, im = alg.run_variation_check(match_type, item_type)
     print('---')
-    print('%s %s Duplicate Results:'%(match_type, item_type))
+    print(('%s %s Duplicate Results:'%(match_type, item_type)))
     for k, matches in list(im.items()):
         texts = ['%s (%d)'%(dm[i],cm[i]) for i in matches]
-        print('  %s (%d) => {%s}'%(dm[k], cm[k], ', '.join(texts)))
+        print(('  %s (%d) => {%s}'%(dm[k], cm[k], ', '.join(texts))))
 
 # For testing, run from command line with this:
 # calibre-debug -e algorithms.py
