def base_repr(number, base=2, padding=0):
 chars = u'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 if (number < base):
  return (((padding - 1) * chars[0]) + chars[int(number)])
 max_exponent = int((math.log(number) / math.log(base)))
 max_power = (long(base) ** max_exponent)
 lead_digit = int((number / max_power))
 return (chars[lead_digit] + base_repr((number - (max_power * lead_digit)), base, max((padding - 1), max_exponent)))

def base_repr ( number , base = 2 , padding = 0 ) : chars = u'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' if ( number < base ) : return ( ( ( padding - 1 ) * chars [ 0 ] ) + chars [ int ( number ) ] ) max_exponent = int ( ( math . log ( number ) / math . log ( base ) ) ) max_power = ( long ( base ) ** max_exponent ) lead_digit = int ( ( number / max_power ) ) return ( chars [ lead_digit ] + base_repr ( ( number - ( max_power * lead_digit ) ) , base , max ( ( padding - 1 ) , max_exponent ) ) )
return the representation of a *number* in any given *base* .