def itn(n, digits=8, format=DEFAULT_FORMAT):
 if (0 <= n < (8 ** (digits - 1))):
  s = (('%0*o' % ((digits - 1), n)) + NUL)
 else:
  if ((format != GNU_FORMAT) or (n >= (256 ** (digits - 1)))):
   raise ValueError('overflow in number field')
  if (n < 0):
   n = struct.unpack('L', struct.pack('l', n))[0]
  s = ''
  for i in xrange((digits - 1)):
   s = (chr((n & 255)) + s)
   n >>= 8
  s = (chr(128) + s)
 return s

def itn ( n , digits = 8 , format = DEFAULT_FORMAT ) : if ( 0 <= n < ( 8 ** ( digits - 1 ) ) ) : s = ( ( '%0*o' % ( ( digits - 1 ) , n ) ) + NUL ) else : if ( ( format != GNU_FORMAT ) or ( n >= ( 256 ** ( digits - 1 ) ) ) ) : raise ValueError ( 'overflow in number field' ) if ( n < 0 ) : n = struct . unpack ( 'L' , struct . pack ( 'l' , n ) ) [ 0 ] s = '' for i in xrange ( ( digits - 1 ) ) : s = ( chr ( ( n & 255 ) ) + s ) n >>= 8 s = ( chr ( 128 ) + s ) return s
convert a python number to a number field .