import string


def num_to_str(num, b=36, numerals=string.digits + string.ascii_lowercase):
    """
    Converts integer num into a string representation on base b
    @param b {int} base to use
    @param numerals {string} characters used for string representation
    @returns {string} string representation of num in base b
    """
    # http://stackoverflow.com/questions/2267362/convert-integer-to-a-string-in-a-given-numeric-base-in-python
    return ((num == 0) and numerals[0]) \
            or (num_to_str(num // b, b, numerals).lstrip(numerals[0]) + numerals[num % b])