--- a/guess.py
+++ b/guess.py
@@ -75,10 +75,10 @@
 try:
     _LIBRARY_NAME = "libguess.so.1"
     _LIBRARY = ctypes.cdll.LoadLibrary(_LIBRARY_NAME)
-except AttributeError, e:
+except AttributeError as e:
     # TODO maybe support other other library types than .so?
     raise RuntimeError("Could not find standard C library loader. This system is not supported.")
-except OSError, e:
+except OSError as e:
     raise RuntimeError("""Could not find %s. Make sure that you have libguess installed and that it is compiled as dynamic library.""" % _LIBRARY_NAME)
 
 
@@ -197,19 +197,19 @@
     else:
         try:
             fp = open(source_file, "rb")
-        except IOError, e:
+        except IOError as e:
             sys.stderr.write(str(e) + "\n")
-            print ''
+            print('')
             return 3
 
     data = fp.read()
     fp.close()
     result = determine_encoding(data, region)
     if result is None:
-        print ''
+        print('')
         return 4
     else:
-        print result
+        print(result)
         return 0
 
 if __name__ == "__main__":
