title: python create a set / dict / list and the sum of its values from a single list comprehension
body: <p>I wonder if two list comprehensions are needed to return the ordered pair of a set / dict / list and the sum of the values in the set / dict / list. Here is an example of what I mean:</p>
  
  <pre><code>&gt;&gt;&gt; l = ['abc', 'd', 'efgh', 'ij']
  &gt;&gt;&gt; {i: len(i) for i in l}, sum(len(i) for i in l)
  ({'efgh': 4, 'abc': 3, 'ij': 2, 'd': 1}, 10)
  </code></pre>
  
  <p>Is there a better / more pythonic way to write this than with duplicate <code>for i in l</code> comprehensions?</p>
  
  <p>UPDATE:</p>
  
  <p>I asked this question because I was thinking of the best way to write a particular <code>lambda</code>; i.e.</p>
  
  <pre><code>&gt;&gt;&gt; l = ['abc', 'd', 'efgh', 'ij']
  &gt;&gt;&gt; dict_value = lambda l: ({i: len(i) for i in l}, sum(len(i) for i in l))
  &gt;&gt;&gt; dict_value(l)
  ({'efgh': 4, 'abc': 3, 'ij': 2, 'd': 1}, 10)
  </code></pre>
  
  <p>I asked this question because I am not using <code>len()</code> to calculate the value I want, but rather a expensive calculation. The point below about the for-loop does solve the problem if I define a secondary method rather than a lambda to do work.</p>