As I said, it’s an interesting exercise in any case. I have no idea if the
core devs would be interested in adding it.

There have been a couple recipes on this thread for an iterator, but I
envision something like the range() object — it’s a lazy Sequence, not just
an iterator.

I think that would be pretty cool.

-CHB

On Wed, Feb 9, 2022 at 3:45 AM Aman Pandey <amanpandey5...@gmail.com> wrote:

> I can give it a try, but I have never done it before and anything which I
> should be knowing beforehand because it will be my first time.
>
> I would like to listen from other fellow developers what they think about
> this?
>
>
> On Wed, Feb 9, 2022 at 1:09 PM Christopher Barker <python...@gmail.com>
> wrote:
>
>> I think a datetime.range object could be useful.
>>
>> Perhaps someone can write one and then see if the core devs would accept
>> it in the stdlib.
>>
>> It would be na interesting exercise in any case :-)
>>
>> -CHB
>>
>> On Tue, Feb 8, 2022 at 10:38 PM Aman Pandey <amanpandey5...@gmail.com>
>> wrote:
>>
>>> 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/
>>>
>>
>>
>> --
>> Christopher Barker, PhD (Chris)
>>
>> Python Language Consulting
>>   - Teaching
>>   - Scientific Software Development
>>   - Desktop GUI and Web Development
>>   - wxPython, numpy, scipy, Cython
>>
> --
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/RSQIISOBSLMRIPDP576PNM3MZ4CQJYX2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to