Hello Stephen, I think you misunderstood it. we are not talking about modifying the existing built-in function range rather adding a new function in datetime module that will generate the date and time between two periods. if we add a function like that in the datetime module the code will be exactly like the one you gave. Christopher was mentioning that he visualizes that function in the datetime module as something similar in syntax and execution like the built-in range function.
what do you think if we add some function like that in datetime module wouldn't it be helpful? On Thu, Feb 10, 2022 at 4:56 PM Stephen J. Turnbull < stephenjturnb...@gmail.com> wrote: > Christopher Barker writes: > > > 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 would be strongly against an extension to range() itself (I think > that was the original proposal), and I think we haven't even started > to mix the batter let alone bake the cake for a range method on > datetime (or time or date). I see the following issues that would > need to be discussed: > > 1. clock monotonicity > 2. "daylight saving" monotonicity > 3. handling of "naive" datetimes (probably easy, but that's what > everybody says about everything) > 4. The "anywhere on earth" (AOE) "timezone" and other similar not- > exactly-what-you-teach-1st-graders-about-time practices. > > There's probably more, but given the above, but I don't see a good > reason to say anything but """what's wrong with > > dt = datetime(*startdate) > while dt <= datetime(*enddate): > do_something_with(dt) > dt += timedelta(*deltaspec) > """ > > yet. It's possible that all of the above are straightforward to deal > with (2 would be messy at best with an indexable dateteime_range, > though), but the monotonic clock PEP was quite a bit of work. They > need to be addressed though. > >
_______________________________________________ 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/72AJBXOJKGUZBX2VLTJEX5WWM53M6JX5/ Code of Conduct: http://python.org/psf/codeofconduct/