title: An autoincrementing callable?
body: <p>I have a method within which I need to pass an ever-increasing integer to another function. </p>
  
  <p>I can do this like so:</p>
  
  <pre><code>def foo(i):
      print i
  
  def bar():
  
      class Incrementer(object):
          def __init__(self, start=0):
              self.i = start
  
          def __get__(self):
              j = self.i
              self.i += 1
              return j
  
      number = Incrementer()
      foo(number)
      foo(number)
      foo(number)
  </code></pre>
  
  <p>which correctly outputs <code>0 1 2 ...</code> but I feel like I'm overlooking a much easier (or built-in) way of doing this? </p>