If lv stores a long value, and the machine is 32 bits, the following code:
iv = int(lv & 0xffffffff)
results an iv of type long, inst
import ctypes number = lv & 0xFFFFFFFF signed_number = ctypes.c_long(number).value