title: __next__ in generators and iterators and what is a method-wrapper?
body: <p>I was reading about generator and iterators and the role of <code>__next__()</code> . </p>
  
  <p><code>'__next__' in dir(mygen)</code>. is true</p>
  
  <p><code>'__next__' in dir(mylist)</code>,  is false</p>
  
  <p>As I looked deeper into it, </p>
  
  <p><code>'__next__' in dir (mylist.__iter__())</code> is true</p>
  
  <ol>
  <li><p>why is<code>__next__</code> only available to list but only to <code>__iter__()</code> and <code>mygen</code> but not <code>mylist</code>. How does <code>__iter__()</code> call <code>__next__</code> when we are stepping thru the list using list-comprehension</p>
  
  <p>Trying to manually step (+1) up the generator, I called <code>mygen.__next__()</code>. It doesn't exist. It only exist as <code>mygen.__next__</code>which is called method-wrapper.</p></li>
  <li><p>what is a method-wrapper and what does it do? How is it applied here: in <code>mygen() and __iter__() ?</code></p></li>
  <li><p>if <code>__next__</code> is what both generator and iterator provide (and their sole properties) then what is the difference between generator and iterator?*</p>
  
  <p>Answer to 3: Solved, as noted by mod/editor:</p>
  
  <p><a href="https://stackoverflow.com/questions/2776829/difference-between-pythons-generators-and-iterators">Difference between Python&#39;s Generators and Iterators</a></p></li>
  </ol>
  
  <p>UPDATE: both generator and iterator have <code>__next__()</code>. My mistake. Looking at the logs, somehow <code>mygen.__next__()</code> test was giving me stopiteration exception error. But I wasn't able to duplicate that error again.</p>
  
  <p>Thanks everyone for answering!</p>