I wanted to display the bytes_downloaded with separator for thousands (e.g. 100,000).

locale.setlocale(locale.LC_ALL, '') sets the local formatting standards things such as numbers or currency and with 

bytes_formatted = locale.format("%d", bytes_downloaded, grouping=True) # returns a string

the number is formatted according to specifications. grouping=True is needed to get the separators. For more information best check http://docs.python.org/2/library/locale.html#locale.setlocale .

I hope that answers your question.