Thousands Seperator in Python
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators-in-python-2-x">how to print number with commas as thousands separators in Python 2.x</a>  </p>
</blockquote>



<p>Does anyone know of an easier way to make numbers have thousands separation than this:</p>

<pre><code>def addComma(num):
    (num, post) = str(num).split('.')
    num = list(num)
    num.reverse()

    count = 0
    list1 = []

    for i in num:
        count += 1
        if count % 3 == 0:
            list1.append(i)
            list1.append(',')
        else:
            list1.append(i)

    list1.reverse()

    return ''.join(list1).strip(',') + '.' + post
</code></pre>

<p>It works, but it seems REALLY fragile...</p>
