title: Get (year,month) for the last X months
body: <p>I got a very simple thing to to in python:
  I need a list of tuples <code>(year,month)</code> for the last x months starting (and including) from today. So, for x=10 and today(July 2011), the command should output:</p>
  
  <pre><code>[(2011, 7), (2011, 6), (2011, 5), (2011, 4), (2011, 3), 
  (2011, 2), (2011, 1), (2010, 12), (2010, 11), (2010, 10)]
  </code></pre>
  
  <p>Only the default datetime implementation of python should be used. I came up with the following solution:</p>
  
  <pre><code>import datetime
  [(d.year, d.month) for d in [datetime.date.today()-datetime.timedelta(weeks=4*i) for i in range(0,10)]]
  </code></pre>
  
  <p>This solution outputs the correct solution for my test cases but I'm not comfortable with this solution: It assumes that a month has four weeks and this is simply not true. I could replace the <code>weeks=4</code> with <code>days=30</code> which would make a better solution but it is still not correct.</p>
  
  <p>The other solution which came to my mind is to use simple maths and subtract 1 from a months counter and if the month-counter is 0, subtract 1 from a year counter. The problem with this solution: It requires more code and isn't very readable either.</p>
  
  <p>So how can this be done correctly?</p>