title: Identify the number of elements in a python struct/pack fmt string?
body: <p>When using the python struct module on can specify a format string that declares how binary data should be interpreted:</p>
  
  <pre><code>&gt;&gt;&gt; from struct import *
  &gt;&gt;&gt; fmt = 'hhl'
  &gt;&gt;&gt; values = [1,2,3]
  &gt;&gt;&gt; blob = pack(fmt, values)
  </code></pre>
  
  <p>It is easily possible to calculate the amount of bytes needed to store an instance of that format:</p>
  
  <pre><code>&gt;&gt;&gt; calcsize(fmt)
  </code></pre>
  
  <p>What would be the best way to retrieve the number of variables need to 'fill' a format? Basically this would tell in advance how big the 'values' array should be to perform the pack() in the above example.</p>
  
  <pre><code>&gt;&gt;&gt; calcentries(fmt)
  3
  </code></pre>
  
  <p>Is there such a thing?</p>