How to pass arguments to function of callable-iterator in python?
<p>Python 2.6.2</p>

<pre><code>&gt;&gt;&gt; call_iter = iter(lambda x: x + 1, 100)
&gt;&gt;&gt; call_iter.next()
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: &lt;lambda&gt;() takes exactly 1 argument (0 given)
</code></pre>

<p>I want to pass argument to <code>lambda x:x + 1</code>.</p>

<p>Update: I think the example above is hard to understand.</p>

<p>I wonder whether there is a builtin func like myiter in python:</p>

<pre><code>class myiter:
    def __init__(self, callable, initial, sentinel):
        self.value = initial
        self.callable = callable
        self.sentinel = sentinel

    def __iter__(self):
        return self

    def next(self):
        if self.value == self.sentinel:
            raise StopIteration
        else:
            # calculate next value from prev value
            self.value = self.callable(self.value) 
            return self.value

if __name__ == '__main__':
    call_iter = myiter(lambda x:x + 1, 0, 100)
    for i in call_iter:
        print i
</code></pre>
