title: Filter out 'None' from Python list, 'str' object is not callable
body: <p>My script does an LDAP search:</p>
  
  <pre><code>import ldap
  ...&lt;initializations&gt;
  res = conn.search_s(base, scope_level, filter, attrs)
  _logger.debug("LDAP query result: %s", res)
  
  # Filter out the 'None' entries for referrals
  filter(lambda x: (isinstance(x,tuple) and x[0] is not None), res)
  </code></pre>
  
  <p>This filter here errors out with <code>TypeError: 'str' object is not callable</code></p>
  
  <p>I added <code>try...except</code> around it to log <code>_logger.debug("Result was:%s, Result type: %s", res, type(res))</code> and it is indeed a list</p>
  
  <pre><code># Example:
  Result was:[('CN=Domain Admins,CN=Users,DC=hiccups,DC=com',
  {'sAMAccountName': ['domain admins']}),
  (None, ['ldap://sirius.hiccups.com/DC=sirius,DC=hiccups,DC=com']),
  (None, ['ldap://ForestDnsZones.hiccups.com/DC=ForestDnsZones,DC=hiccups,DC=com']),
  (None, ['ldap://DomainDnsZones.hiccups.com/DC=DomainDnsZones,DC=hiccups,DC=com']),
  (None, ['ldap://hiccups.com/CN=Configuration,DC=hiccups,DC=com'])],
  Result type: &lt;type 'list'&gt;
  </code></pre>
  
  <p>If I copy the list in a separate script and run the same filter, it works as expected.</p>
  
  <p>A <code>for</code> construct replacing <code>filter</code> also works fine:</p>
  
  <pre><code>result = []
  for each in res:
  if (isinstance(each, tuple) and each[0] is not None):
      result.append(each)
  </code></pre>
  
  <p>But I want to debug why <code>filter</code> is failing</p>