> strfmt = lambda x:"".join(map(lambda c,l,y=len(x):(l==3) and c+"," or > (not (l-3)%3 and c+"." or c),list(x),range(len(x),0,-1))) Needs a little more tweaking; try this: strfmt(str(-10000))