title: How can I test to see if a defaultdict(set) is empty in Python
body: <p>I have a defaultdict <code>fishparts = defaultdict(set)</code> that has elements assigned to it but is periodically cleared using <code>.clear()</code> What I need is some way to test if the set is clear or not so I can do some other work in the function below.</p>
  
  <pre><code>def bandpassUniqReset5(player,x,epochtime):
      score = 0
      if lastplay[player] &lt; (epochtime - 300):
          fishparts[player].clear()
      lastplay[player] = epochtime
      for e in x:
          # right here I want to do a check to see if the "if" conditional above has cleared fishparts[player] before I do the part below
          if e not in fishparts[player]:
              score += 1
          fishparts[player].add(e)
      return str(score)
  </code></pre>