title: python date of the previous month
body: <p>I am trying to get the date of the previous month with python.
  Here is what i've tried:</p>
  <pre><code>str( time.strftime('%Y') ) + str( int(time.strftime('%m'))-1 )
  </code></pre>
  <p>However, this way is bad for 2 reasons: First it returns 20122 for the February of 2012 (instead of 201202) and secondly it will return 0 instead of 12 on January.</p>
  <p>I have solved this trouble in bash with</p>
  <pre><code>echo $(date -d&quot;3 month ago&quot; &quot;+%G%m%d&quot;)
  </code></pre>
  <p>I think that if bash has a built-in way for this purpose, then python, much more equipped, should provide something better than forcing writing one's own script to achieve this goal. Of course i could do something like:</p>
  <pre><code>if int(time.strftime('%m')) == 1:
      return '12'
  else:
      if int(time.strftime('%m')) &lt; 10:
          return '0'+str(time.strftime('%m')-1)
      else:
          return str(time.strftime('%m') -1)
  </code></pre>
  <p>I have not tested this code and i don't want to use it anyway (unless I can't find any other way:/)</p>
  <p>Thanks for your help!</p>