title: How to get the current value of a Python iterator - dereferencing an iterator without incrementing
body: <p>In C++ I can access the value pointed to by an iterator <code>it</code>, as well as surrounding ones (which is not always safe, but that's off topic here), using dereference: <code>std::cout &lt;&lt; &quot;prev: &quot; &lt;&lt; *(it-1) &lt;&lt; &quot;, here: &quot; &lt;&lt; *it &lt;&lt; &quot;, next: &quot; &lt;&lt; *(it+1) &lt;&lt; std::endl;</code></p>
  <p>How do I do the same in Python?</p>
  <p>Using <code>next()</code> I can get the current value, but that also increments the iterator (similar to C++ <code>*it++</code>).</p>
  <p>Complete code example below:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  int main() 
  {
      std::vector&lt;int&gt; myvector{ 1, 2, 3, 4, 5 };
      for (auto it = myvector.begin()+1; it != myvector.end()-1; ++it) {
          std::cout &lt;&lt; &quot;prev: &quot; &lt;&lt; *(it-1) &lt;&lt; &quot;, here: &quot; &lt;&lt; *it &lt;&lt; &quot;, next: &quot; &lt;&lt; *(it+1) &lt;&lt; std::endl;
      }
      return 0;
  }
  </code></pre>