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
This is an old question but I thought i'd share my take on it as I feel it is somewhat simpler that other answers (good for bases from 2 to 36):
def intStr(n,base=10):
if n < 0 : return "-" + intStr(-n,base) # handle negatives
if n < base: return chr([48,55][n>9] + n) # 48 => "0"..., 65 => "A"...
return intStr(n//base,base) + intStr(n%base,base) # recurse for multiple digits