Python's calendar module is part of the standard library. It allows the output of a calendar by month or by year and also provides other, calendar-related functionality.
The calendar module itself depends on the datetime module. But we will also need datetime for our own purposes, as we will see. So we should import both of these. Also, in order to do some string splitting, we will need the re module. Let's import them all in one go.
import re, datetime, calendar
By default, the calendars begin the week with Monday (day 0), per the European convention, and ends with Sunday (day 6). If you prefer Sunday as the first day of the week, use the setfirstweekday() method to change the default to day 6 as follows:
calendar.setfirstweekday(6)
To toggle between the two, you could pass the first day of the week as an argument using the sys module. You would then check the value with an if statement and set the setfirstweekday() method accordingly.
import sys
firstday = sys.argv[1]
if firstday == "6":
calendar.setfirstweekday(6)
