title: Get only the last element of an iterator in the most Pythonic way
body: <p>How do I get the last element of an iterator?  I'm aware that I have to exhaust the iterator and return the last value it produced, so the plain approach would be:</p>
  
  <pre><code>def last(it):
      for value in it:
          pass
      return value
  </code></pre>
  
  <p>(You might want to catch the <code>NameError</code> and raise something else for empty input, but you get the idea.)</p>
  
  <p>Is there a simpler solution I didn't think of, e. g. using <code>itertools.islice()</code> (it doesn't seem to accept negative indexes, though) or something similar?</p>