title: The number of calendar weeks in a year?
body: <p>In Python, how can we find out the number of calendar weeks in a year? </p>
  
  <p>I didn't find a function in the standard library. </p>
  
  <p>I then thought about <code>date(year, 12, 31).isocalendar()[1]</code>, but</p>
  
  <blockquote>
    <p>For example, 2004 begins on a Thursday, so the first week of ISO year 2004 begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004, so that <code>date(2003, 12, 29).isocalendar() == (2004, 1, 1)</code> and <code>date(2004, 1, 4).isocalendar() == (2004, 1, 7)</code>.</p>
  </blockquote>