Tim Williams wrote:
>>>> a = 1890284
>>>> ','.join([str(a)[::-1][x:x+3] for x in range(len(str(a)))[::3]])[::-1]
> '1,890,284'
> 
> Ugly !
> 

 >>> b = 189028499
 >>> ','.join([str(b)[::-1][x:x+3] for x in range(len(str(b)))[::3]])[::-1]

'-,189,028,499'

 >>> c = 1890284.1
 >>> ','.join([str(c)[::-1][x:x+3] for x in range(len(str(c)))[::3]])[::-1]

'189,028,4.1'


Stick to using locale. :)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to