iterator class using generator function
Looks like a lot of extra code for very little gain, considering you can simply call iter() on an iterable object to return an iterator:

&gt;&gt;&gt; c = C()
&gt;&gt;&gt; i = iter(c)
&gt;&gt;&gt; next(i)
0
&gt;&gt;&gt; next(i)
1
&gt;&gt;&gt; next(i)
2
&gt;&gt;&gt; c.state
1


Also, note your new class C can have more than one iterator, with only 1 "state".  The first iterator is created automatically by the constructor, for use with the next(c) call.  Additional iterators are created each time you start looping over c, since iter(c) gets called and returns a new generator!

&gt;&gt;&gt; c = C()
&gt;&gt;&gt; next(c)
0
&gt;&gt;&gt; print(next(c), c.state)
1 0
&gt;&gt;&gt; print(next(c), c.state)
2 1
&gt;&gt;&gt; for x in c: print(x, c.state)       # Start a new iteration
...
0 1
1 0
2 1
3 2
&gt;&gt;&gt; print(next(c), c.state)             # Continue original iteration
3 2
&gt;&gt;&gt; next(c)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "&lt;stdin&gt;", line 9, in __next__
StopIteration