docs: def encode(number, alphabet):
      """
      Converts an integer to a base n string where n is the length of the
      provided alphabet.
  
      Modified from http://en.wikipedia.org/wiki/Base_36
      """
      if not isinstance(number, (int, long)):
          raise TypeError("Number must be an integer.")
  
      base_n = ""
      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))
          base_n = alphabet[i] + base_n
  
      return sign + base_n