title: Is it possible to access current object while doing list/dict comprehension in Python?
body: <p>Trying to think of a one-liner to achieve the following ( summing all the values of a key) :</p>
  
  <pre><code>&gt;&gt;&gt; data = [('a',1),('b',3),('a',4),('c',9),('b',1),('d',3)]
  &gt;&gt;&gt; res = {}
  &gt;&gt;&gt; for tup in data:
  ...     res[tup[0]] = res.setdefault(tup[0],0) + tup[1]
  ... 
  &gt;&gt;&gt; res
  {'a': 5, 'c': 9, 'b': 4, 'd': 3}
  </code></pre>
  
  <p>One-liner version without using any imports like itertools,collections etc.</p>
  
  <pre><code> { tup[0] : SELF_REFERENCE.setdefault(tup[0],0) + tup[1]  for tup in data }
  </code></pre>
  
  <p>Is it possible in Python to use a reference to the object currently being comprehended ?
  If not, is there any way to achieve this in a one-liner without using any imports i.e. using 
  basic list/dict comprehension and inbuilt functions.</p>