Return quarters of current year I build this simple function, trying to use PEP 8 Style, something that I discovered recently thanks to this previous question.
The function works, but I was wondering if there is a better way to do it.
import datetime

def quarter_values_builder():
    &quot;&quot;&quot;A function that returns an array
    with all the actual year quarters
    &quot;&quot;&quot;
    now = datetime.datetime.now()
    year = now.year
    year_str = str(year)
    quarter_values = [&quot;31/03/&quot;,&quot;30/06/&quot;,&quot;30/09/&quot;,&quot;31/12/&quot;] 
    quarter_values_now = [x+year_str for x in quarter_values]

    return quarter_values_now

current_quarters_string = quarter_values_builder()
print(current_quarters_string)
Without seeing the rest of your code it's difficult to say how this is used, but I think your function has conflated logic and formatting, and formatting is being done too soon. You should hold onto real date information right up until the edges of your program when that's possible. The following demonstrates one way of keeping dates and moving them to the current year.
from datetime import date, timedelta
from typing import Iterable, Tuple

QUARTER_DATES = (
    date(2000, 3, 31),
    date(2000, 6, 30),
    date(2000, 9, 30),
    date(2000, 12, 31),
)


def get_current_quarters() -&gt; Iterable[date]:
    year = date.today().year
    for quarter in QUARTER_DATES:
        yield quarter.replace(year=year)


print('\n'.join(d.strftime('%d/%m/%Y') for d in get_current_quarters()))

dd-mm-YYYY is also an ambiguous and non-sortable format. Your usage (which you have not shown) will either need this to be &quot;machine-readable&quot; - e.g. for logs, REST payloads, etc. - or human-readable, e.g. for a UI. If you need machine readability, the ISO yyyy-mm-dd format is strongly preferred. If you need human readability, rather than hard-coding dd/mm/YYYY, your code should obey the current locale (not shown above).