title: Loop through dates except for weekends
body: <p>So I have a script that has date arguments for different functions and I want it to loop through <code>01-01-2012</code> to <code>06-09-2012</code> not including weekends. Im trying to figure out a way I can use time delta because my script outputs files with the date used in the name of the file for example:</p>
  
  <pre><code>items = (functions.getItems(item,date)
      print items
      test = sum(abs(l[-1]) for l in items)
      total = open('total' +str(datetime.today- datetime.timedelta(1)),'a')
  </code></pre>
  
  <p>I want timedelta(1) to cycle through each date so that the output file would have the format of <code>total2012-01-01</code> for the first day and cycle through until it created the file <code>total2012-06-09</code>. Also the date argument for items has the format of <code>MM-DD-YYYY</code></p>
  
  <p>I thought that I could do this: </p>
  
  <pre><code>sd = 01-01-2012
  ed = 06-09-2012
  delta = datetime.timedelta(days=1)
  diff = 0
  while sd != ed
      # do functions 
      # (have output files (datetime.today - datetime.delta(diff))
      diff +=1
      sd+=delta
  </code></pre>
  
  <p>So essentially I'm just trying to figure out how can I loop through having the function start with <code>01-01-2012</code> and ending with <code>06-10-2012</code> excluding weekends. I'm having trouble figuring out how to exclude weekends and how to get it to loop in the proper order</p>
  
  <p>Thanks </p>