title: Python number print formatting using %.*g
body: <p>I found this python example online and I'd like to understand exactly how the number formatting works:</p>
  
  <pre><code>print "%.*g\t%.*g" % (xprecision, a, yprecision, b)
  </code></pre>
  
  <p>I can see by experimentation that this prints a (with precision xprecision), a tab and then b (with precision yprecision).  So, as a simple example, if I run</p>
  
  <pre><code>print "%.*g\t%.*g" % (5, 2.23523523, 3, 12.353262)
  </code></pre>
  
  <p>then I get</p>
  
  <pre><code>2.2352  12.4
  </code></pre>
  
  <p>I understand how <code>%g</code> usually works.  I also understand how the <code>%</code> generally works.  What is confusing me in this example is the construct <code>%.*g</code>.  How does the <code>*</code> work here?   I can see that it is somehow taking the desired precision value and substituting it into the print expression, but why is that happening?  Why does the precision number appear before the number being formatted in (xprecision, a...)?  </p>
  
  <p>Can someone break this down and explain it to me?</p>