Hrvoje Niksic: > I'm surprised that no one has proposed a regex solution, such as:
I presume many Python programmers aren't much used in using REs. > >>> import re > >>> re.sub(r'\d{1,3}(?=(?:\d{3})+$)', r'\g<0>.', str(1234567)) > '1.234.567' It works with negative numbers too. It's a very nice solution of a simple problem that shows what you can do with REs. But I think that RE has to be expanded & splitted (and maybe even commented) with a VERBOSE, to improve readability, maybe somethign like: \d {1,3} (?= # lockahead assertion (?: \d {3} )+ $ # non-group ) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list