title: Is there an alternative to this code that looks neater and is more comprehensible?
body: <p>I have this code which loops through a set, and checks to see if one of the items in the set is a folder, and if it is, it checks to see which folder it is and then proceeds to perform an action based on what folder it is. I'm not really sure how to explain why there are two loops, so I'm hoping you guys can look at it and understand why I did that, because it doesn't work without it.</p>
  
  <p>You can see why I'm wondering if it can be cleaned up...</p>
  
  <p>In this case, the value of neededdirs is</p>
  
  <pre><code>set(['Pictures', 'Downloads', 'Public', 'Desktop'])
  </code></pre>
  
  <p>and here's the main code which needs to be cleaned up.</p>
  
  <pre><code>neededdirs = folders.findKeyDir('active') #declares the set
  for x in neededdirs: #starts the main loop
      for y in neededdirs: #starts the second loop
          if folders.getObject(neededdirs, y, 'bool'): #checks to see if the the option in the set is a folder.
              neededname = folders.getObject(neededdirs, y, 'name') #retrieves the name of the item in the set.
              if neededname == "Desktop": #this and all elif's after just check its name.
                  self.folderheader1.setText(_translate("MainWindow", "Status: Active", None)) #this, the line after, and all others like it just change the text on an item if it evaluates to true.
                  self.folderactive.setChecked(True)
              elif neededname == "Documents":
                  self.folderheader2.setText(_translate("MainWindow", "Status: Active", None))
                  self.folderactive_2.setChecked(True)
              elif neededname == "Downloads":
                  self.folderheader3.setText(_translate("MainWindow", "Status: Active", None))
                  self.folderactive_3.setChecked(True)
              elif neededname == "Music":
                  self.folderheader4.setText(_translate("MainWindow", "Status: Active", None))
                  self.folderactive_4.setChecked(True)
              elif neededname == "Pictures":
                  self.folderheader1_2.setText(_translate("MainWindow", "Status: Active", None))
                  self.folderactive_5.setChecked(True)
              elif neededname == "Public":
                  self.folderheader1_3.setText(_translate("MainWindow", "Status: Active", None))
                  self.folderactive_6.setChecked(True)
              elif neededname == "Templates":
                  self.folderheader1_4.setText(_translate("MainWindow", "Status: Active", None))
                  self.folderactive_7.setChecked(True)
              elif neededname == "Videos":
                  self.folderheader1_5.setText(_translate("MainWindow", "Status: Active", None))
                  self.folderactive_8.setChecked(True)
  </code></pre>
  
  <p>Thanks in advance.</p>