Python allows easy creation of an integer from a string of a given base via
int(str, base). 
I want to perform the inverse: creati
Well I personally use this function, written by me
import string
def to_base(value, base, digits=string.digits+string.ascii_letters):    # converts decimal to base n
    digits_slice = digits[0:base]
    temporary_var = value
    data = [temporary_var]
    while True:
        temporary_var = temporary_var // base
        data.append(temporary_var)
        if temporary_var < base:
            break
    result = ''
    for each_data in data:
        result += digits_slice[each_data % base]
    result = result[::-1]
    return result
This is how you can use it
print(to_base(7, base=2))
Output:
"111"
print(to_base(23, base=3))
Output:
"212"
Please feel free to suggest improvements in my code.