Improved portability between Python 2 and Python 3. Beginnings of code for writing SEG Y.

This commit is contained in:
Robert Smallshire
2014-10-21 14:54:49 +02:00
parent 1abff28a40
commit ee228e2dc9
9 changed files with 274 additions and 23 deletions
+31 -1
View File
@@ -1,4 +1,7 @@
import os
import sys
EMPTY_BYTE_STRING = b'' if sys.version_info >= (3, 0) else ''
def seekable(fh):
@@ -21,4 +24,31 @@ def seekable(fh):
fh.seek(pos)
except AttributeError:
return False
return True
return True
if sys.version_info >= (3, 0):
long_int = int
else:
long_int = long
if sys.version_info >= (3, 0):
def byte_string(integers):
return bytes(integers)
else:
def byte_string(integers):
return ''.join(chr(i) for i in integers)
if sys.version_info >= (3, 0):
import reprlib
reprlib = reprlib # Keep the static analyzer happy
else:
import repr as reprlib
if sys.version_info >= (3, 0):
izip = zip
else:
from itertools import izip
izip = izip # Keep the static analyzer happy