Tim Chase wrote:
tekion wrote:
Is there a module where you could figure week of the day, like where
it starts and end. I need to do this for a whole year. Thanks.

the monthcalendar() call returns the whole month's calendar which may be more what you want for the big-picture.

And if you want a whole year's worth, you can get pretty close with:

  import itertools as i
  import calendar as c
  for month in range(1,13):
    for week in c.monthcalendar(2009, month):
      print repr(w)

You don't detail how you want the month-boundaries to behave, so this gives "calendar"'s default behavior of filling in zeros on month-boundaries, so November through the 1st week in Dec 2009 comes back as

  ...
  [0, 0, 0, 0, 0, 0, 1],
  [2, 3, 4, 5, 6, 7, 8],
  [9, 10, 11, 12, 13, 14, 15],
  [16, 17, 18, 19, 20, 21, 22],
  [23, 24, 25, 26, 27, 28, 29],
  [30, 0, 0, 0, 0, 0, 0],
  [0, 1, 2, 3, 4, 5, 6],
  ...

rather than

  ...
  [26, 27, 28, 29, 30, 31, 1],
  [2, 3, 4, 5, 6, 7, 8],
  [9, 10, 11, 12, 13, 14, 15],
  [16, 17, 18, 19, 20, 21, 22],
  [23, 24, 25, 26, 27, 28, 29],
  [30, 1, 2, 3, 4, 5, 6],
  ...

-tkc



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to