<div dir="ltr"><div>Hi another Steve,</div><div><br></div><div>Your code will not work! You are skipping the other values below it. When, let's say, the minute value reaches 59, the next iterator should return 0. In your code, it will not. It will start with 5. That is not how an odometer wheel works.<br></div><div><br></div><div>Best Regards, <br></div><div>Ronie<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 25, 2018 at 2:59 PM Stephen J. Turnbull <<a href="mailto:turnbull.stephen.fw@u.tsukuba.ac.jp">turnbull.stephen.fw@u.tsukuba.ac.jp</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ronie Martinez writes:<br>
<br>
 > def main():<br>
 >     datetime_odometer = itertools.product(<br>
 >         range(2018, 10_000),  # year<br>
 >         range(1, 13),  # month<br>
 >         range(1, 31),  # days<br>
 >         range(0, 24),  # hours<br>
 >         range(0, 60),  # minutes<br>
 >         range(0, 60)  # seconds<br>
 >     )<br>
 > <br>
 >     datetime_of_interest = (2050, 6, 15, 10, 5, 0)<br>
 > <br>
 >     for i in datetime_odometer:<br>
 >         if i == datetime_of_interest: # target start time<br>
 >             break<br>
<br>
I don't understand the issue.  Doesn't<br>
<br>
    def make_odometer(year, month, day, hour, minute, second):<br>
        return itertools.product(<br>
            range(year, 10_000),<br>
            range(month, 13),<br>
            range(day, 31),<br>
            range(hour, 24),<br>
            range(minute, 60),<br>
            range(second, 61)        # leap seconds!<br>
        )<br>
<br>
    def main():<br>
        datetime_of_interest = (2050, 6, 15, 10, 5, 0)<br>
<br>
        datetime_odometer = make_odometer(*datetime_of_interest)<br>
<br>
do what you want?  If you have a task where that *doesn't* do what's<br>
needed, eg, where the "odometer wheels" are an iterated function<br>
system, I don't see any way to avoid the problem.  If you have some<br>
range-like object that doesn't support starting values, you need to<br>
fix that or there's nothing that could be done about it in itertools.<br>
<br>
(Yet Another) Steve<br>
<br>
-- <br>
Associate Professor              Division of Policy and Planning Science<br>
<a href="http://turnbull.sk.tsukuba.ac.jp/" rel="noreferrer" target="_blank">http://turnbull.sk.tsukuba.ac.jp/</a>     Faculty of Systems and Information<br>
Email: <a href="mailto:turnbull@sk.tsukuba.ac.jp" target="_blank">turnbull@sk.tsukuba.ac.jp</a>                   University of Tsukuba<br>
Tel: 029-853-5175                 Tennodai 1-1-1, Tsukuba 305-8573 JAPAN<br>
</blockquote></div>