On Tue, 8 Feb 2022 at 14:00, Aman Pandey <amanpandey5...@gmail.com> wrote: > > I wanted to generate all the dates between two date ranges for which I was > using count function in the itertools and to my surprise count function > doesn't support datetime operation. > > For example > >import datetime > >from itertools import count > >count(datetime.date.today(), datetime.timedelta(1)) > > Why is count function only limited to numbers shouldn't we make it generic > that it should support operation like datetime where addition between the > objects is possible.
Because it's implemented in C for speed, and limiting it to numbers makes it both easier to implement (in C) and faster. > Would like to hear thoughts from you people. start = date.datetime.today() (start + datetime.timedelta(n) for n in count()) does exactly the same as your code does, so it's not *that* hard to get the functionality you want already. Paul _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/H5KBZIBFRSVFW2ZWDCHU4CXJ5X36COWU/ Code of Conduct: http://python.org/psf/codeofconduct/