title: Nested dictionary comprehension to avoid empty values
body: <p>I have an api call that returns a dictionary with all the ids for all users
  and others to get the <code>userDetails</code> like:</p>
  
  <pre><code>&gt;&gt;&gt; allIds=api.getAllIds()
  {1,2,3,4,5}
  &gt;&gt;&gt; userDetails=api.getUserDetails(1)
  {'name':'Bob','age':'19'}
  </code></pre>
  
  <p>I'm trying to pack the whole structure in a dict with the <code>userId</code>-like key and the info-like value.</p>
  
  <p>I could make it work with:</p>
  
  <pre><code>&gt;&gt;&gt; users={id:api.getUserDetails(id) for id in allIds}
  {1:{'name':'bob','age':'19'},2:None,3:{'name':'alice','age':'21'},...}
  </code></pre>
  
  <p>The problem is that not all Ids returns a response as you can see for the id 2 call. I'm trying not to use traditional loops and I'm solving the situation cleaning the resulting <code>dict</code> after the calls with:</p>
  
  <pre><code>&gt;&gt;&gt; users=[id:users[id] for id in users.keys() if users[id]!=None]
  </code></pre>
  
  <p>It's working, but I'm trying not to put inside the empty values instead of cleaning. In a normal situation you could create the dict like:</p>
  
  <pre><code>&gt;&gt;&gt; a=[id:b[id] for id in b.keys() if b[id]!=None ]
  </code></pre>
  
  <p>But in my case if I check if <code>b[i]</code> is None... then I'm calling the api two times because my <code>b[i]</code> expression is <code>api.getUserDetails(id)</code>, one to take the value and the other to check if is not None.</p>
  
  <p>So I'm trying something like nested dictionary comprehension:</p>
  
  <pre><code>users = {(x,y) for x in usersIds for y in api.getUserDetails(x) if y!=None }
  </code></pre>
  
  <p>But I can not make it work.</p>
  
  <p>Anyone know how to do it?</p>