title: Index, for loops and making things look cleaner
body: <p>I have a number of objects that represent various versions of a letter. Some of these versions have been printed (timedate stamped). If a letter (with all it's versions) has been printed I need to get the timedate stamp of the last printed version (easily done), and then the version number of the last printed version (currently making my code look like C++{shiver}).</p>
  
  <p>So how do I make this look more pythonic (cleaner)</p>
  
  <pre><code>try:
      # get the lastest letter version that has been printed
      lv_temp = LV.objects.filter(letter=letter.id,printed_last__isnull=False).latest('id')
      # get the id's of all the letter versions for a particular letter
      lv_temp2 = LV.objects.filter(letter=letter.id).order_by('id')
      lv_temp4 = []
      # get all the letter version for a particular letter
      for lv_temp3 in lv_temp2:
          lv_temp4.append(lv_temp3.id)
      # get an array of the indexes and the pks
      for i,v in enumerate(lv_temp4) :
          # if the pk of the last printed version is the same one as in the loop...
          if lv_temp.id == v :
              # ...save the index as the version number
              lv_printed_ver = i
      lv_printed = lv_temp.printed_last
  except ObjectDoesNotExist:
      lv_printed = None
      lv_printed_ver = None
  </code></pre>
  
  <p><em>(I used <code>lv_temp...</code> because I was getting angry how many times I had to pass things)</em></p>