master
unknown 2015-07-05 19:28:27 -07:00
parent 87f4c44976
commit fa71076e40
1 changed files with 3 additions and 0 deletions

View File

@ -11,6 +11,9 @@ TERMINALWIDTH = shutil.get_terminal_size().columns
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' % (
alphabet, base))
alphabet = alphabet[:base]
if not isinstance(number, (int, str)):
raise TypeError('number must be an integer')