title: How to log number with commas as thousands separators?
body: <p>The time has come to convert all prints into logging calls in a library I'm maintaining.  Some of the print calls are using <code>str.format</code>, like this (simplified):</p>
  
  <pre><code>&gt;&gt;&gt; n = 4000000
  &gt;&gt;&gt; print(f"this bird wouldn't voom if you put {n:,} volts through it!")
  this bird wouldn't voom if you put 4,000,000 volts through it!
  </code></pre>
  
  <p>When I try to log it:</p>
  
  <pre><code>&gt;&gt;&gt; log.warning("this bird wouldn't voom if you put %d, volts through it!", n)
  WARNING:root:this bird wouldn't voom if you put 4000000, volts through it!
  </code></pre>
  
  <p>Seems this is not specifying the thousands separator correctly.  How do you specify the thousands separator when using the %-formatting syntax which Python's stdlib logging module necessitates?  </p>
  
  <p>Currently using this workaround, which does give the desired output, but seems wrong since the variable is formatted first using <code>str.format</code> and then formatted as a string again, instead of logging as a number directly:</p>
  
  <pre><code>&gt;&gt;&gt; log.warning("this bird wouldn't voom if you put %s volts through it!", format(n, ','))
  WARNING:root:this bird wouldn't voom if you put 4,000,000 volts through it!
  </code></pre>