Commits

Sergey Astanin  committed 6f08543

move json imports in demo

  • Participants
  • Parent commits f5e5c3f

Comments (0)

Files changed (1)

 import socket
 import struct
 from collections import namedtuple
-try:
-    from simplejson import dumps, encoder
-    encoder.FLOAT_REPR = lambda o: ("%.4f" % o)
-except ImportError:
-    from json import dumps, encoder
-    encoder.FLOAT_REPR = lambda o: ("%.4f" % o)
 
 
 ###
 
 
 def demo_recv_data():
+    try:
+        from simplejson import dumps, encoder
+        encoder.FLOAT_REPR = lambda o: ("%.4f" % o)
+    except ImportError:
+        from json import dumps, encoder
+        encoder.FLOAT_REPR = lambda o: ("%.4f" % o)
+
     dsock = mkdatasock()
     bufsize = struct.calcsize(PACKET_FORMAT)
     version = (2, 5, 0, 0)