def basex(number, base, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
    """Converts an integer to a different base string."""
    if base > len(alphabet):
        raise Exception('alphabet %s does not support base %d' % (
                         repr(alphabet), base))
    alphabet = alphabet[:base]
    if not isinstance(number, (int, str)):
        raise TypeError('number must be an integer')
    number = int(number)
    based = ''
    sign = ''
    if number < 0:
        sign = '-'
        number = -number
    if 0 <= number < len(alphabet):
        return sign + alphabet[number]
    while number != 0:
        number, i = divmod(number, len(alphabet))
        based = alphabet[i] + based
    return sign + based