Thank you! I made it run like the following. What do you think about that? IS there a better way? #The following runs on Python 2.7 sc3=''' # Python 3 def original(n): m = 0 for b in n.to_bytes(6, 'big'): m = 256*m + b return m ''' if sys.version_info[0] == 3: exec(sc3)