title: What is the current value of a Python itertools counter
body: <p>The <code>itertools.count</code> counter in Python (2.7.9) is very handy for thread-safe counting. How can I get the current value of the counter though?</p>
  
  <p>The counter increments and returns the last value every time you call <code>next()</code>:</p>
  
  <pre><code>import itertools
  x = itertools.count()
  print x.next()  # 0
  print x.next()  # 1
  print x.next()  # 2
  </code></pre>
  
  <p>So far, so good.</p>
  
  <p>I can't find a way to get the current value of the counter without calling <code>next()</code>, which would have the undesirable side-effect of increasing the counter, or using the <code>repr()</code> function.</p>
  
  <p>Following on from the above:</p>
  
  <pre><code>print repr(x)  # "count(3)"
  </code></pre>
  
  <p>So you could parse the output of <code>repr()</code>. Something like</p>
  
  <pre><code>current_value = int(repr(x)[6:-1])
  </code></pre>
  
  <p>would do the trick, but is really ugly.</p>
  
  <p>Is there a way to get the current value of the counter more directly?</p>