I get your point. I checked the code which is in C and implement the
solution which was something similar to yours.
Should we have some function like that in the datetime module that can
generate date, and time as well between two ranges?
This looks like a feature to me that can be helpful.
Yesterday I found Pandas Library has this feature
<https://pandas.pydata.org/docs/reference/api/pandas.date_range.html>. What
do you think?


On Tue, Feb 8, 2022 at 9:23 PM Paul Moore <p.f.mo...@gmail.com> wrote:

> 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/RRVFZA7HYFWCX55TNFOTQ32QQNH75PAH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to