Sure I could write this myself, but before I go reinventing the wheel is there a function that already does this?
Here is a verbose, but also readable solution that will work for datetime and date instances
def get_quarter(date): for months, quarter in [ ([1, 2, 3], 1), ([4, 5, 6], 2), ([7, 8, 9], 3), ([10, 11, 12], 4) ]: if date.month in months: return quarter