]> git.phdru.name Git - dotfiles.git/commitdiff
init.py: minor refactoring: move displayhook
authorOleg Broytman <phd@phdru.name>
Tue, 19 Apr 2016 09:32:54 +0000 (12:32 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 19 Apr 2016 09:32:54 +0000 (12:32 +0300)
lib/python/init.py

index 363a10a1e6d0aaf8ceb66e64dda3296d44f0dc3b..642eb6c6ab545f3f52443768c2fcebb61c056b08 100644 (file)
@@ -114,17 +114,19 @@ def init():
         try:
             locale.setlocale(locale.LC_ALL, '')
 
-            from pprint import pprint
+        except (ImportError, locale.Error):
+            pass  # no locale support or unsupported locale
 
-            def displayhook(value):
-                if value is not None:
-                    __builtin__._ = value
-                    pprint(value)
+    # set displayhook
 
-            sys.displayhook = displayhook
+    from pprint import pprint
 
-        except (ImportError, locale.Error):
-            pass  # no locale support or unsupported locale
+    def displayhook(value):
+        if value is not None:
+            __builtin__._ = value
+            pprint(value)
+
+    sys.displayhook = displayhook
 
     # utilities