[issue28292] Make Calendar.itermonthdates() behave consistently in edge cases

Alexander Belopolsky report at bugs.python.org
Wed Sep 28 12:26:28 EDT 2016


Alexander Belopolsky added the comment:

I would like to take the #1 approach, and also implement an itermonthdays3() generator that would be like  itermonthdates(), but return 3-tuples (year, month, day) instead of datetime.date objects.

The name "itermonthdays3" is subject to discussion, but it fits with the existing "itermonthdays" and "itermonthdays2" that yield integers and 2-tuples respectively.  An alternative, but slightly longer name would be "itermonthdatetuples".

itermonthdates() can then be reimplemented as

def itermonthdates(self, year, month):
    for y, m, d in self.itermonthdays3(year, month):
        yield datetime.date(y, m, d)

with the obvious out of bounds behavior.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28292>
_______________________________________


More information about the Python-bugs-list mailing list