This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ElianMariano
Recipients ElianMariano
Date 2020-11-22.19:46:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606074399.89.0.722883814317.issue42439@roundup.psfhosted.org>
In-reply-to
Content
Inside the file calendar.py, there are two functions which are supposed to calculate the previous and next month relative to the actual year and month.

def _prevmonth(year, month):
    if month == 1:
        return year-1, 12
    else:
        return year, month-1


def _nextmonth(year, month):
    if month == 12:
        return year+1, 1
    else:
        return year, month+1

Because of the concise calculation that is being made by these functions, it would be convenient to use the ternary operator to calculate that. So, the result would be:

def _prevmonth(year, month):
    return [year-1, 12] if month == 1 else [year, month-1]

def _nextmonth(year, month):
    return [year+1, 1] if month == 12 else [year, month+1]
History
Date User Action Args
2020-11-22 19:46:39ElianMarianosetrecipients: + ElianMariano
2020-11-22 19:46:39ElianMarianosetmessageid: <1606074399.89.0.722883814317.issue42439@roundup.psfhosted.org>
2020-11-22 19:46:39ElianMarianolinkissue42439 messages
2020-11-22 19:46:39ElianMarianocreate