To figure out the month range, you can use a built-in function from the calendar library.
1.
from
calendar
import
monthrange
2.
3.
range
=
monthrange(year, month)
4.
(
4
,
31
)
The result will be a tuple, the first value containing the index of the first day of the month and second value holding the number of days in the month.
*update 31/05/2011*
The first value is used to know what day of the week the first day of the month is.
- 0 = Monday
- 1 = Tuesday
- 3 = Wednesday
- ...
- 6 = Sunday
It will correspond with the values in the "calendar" library.
calendar.MONDAY = 0, calendar.SUNDAY = 6
[ Source ]