On Wed, Apr 23, 2008 at 10:35 PM, Alex Martelli &lt;<a href="mailto:aleaxit@gmail.com">aleaxit@gmail.com</a>&gt; wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Is 119 vs 117 characters &quot;a LOT of verbosity&quot;...?! &nbsp;OK, then what about...:</blockquote><div><br>the reduce is actually 69 *and only one line* if you don&#39;t need it in a function. You can&#39;t put the dhms2 in a function unless you want to leak a bunch of variables like &#39;d&#39;, &#39;r&#39;, and &#39;t&#39;...<br>
reduce(lambda a, b: a[:-1] + [a[-1]%b, a[-1]//b], [[t], 60, 60, 24])<br></div></div><br>On Wed, Apr 23, 2008 at 10:40 PM, &quot;Martin v. Löwis&quot; &lt;<a href="mailto:martin@v.loewis.de">martin@v.loewis.de</a>&gt; wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">py&gt; time % 60, time//60%60, time//3600%24, time//(3600*24)<br>
(28, 7, 0, 22)</blockquote><div>the 3600 and 3600*24 was what I was trying to avoid. I like the divmod solution. You can also use it in the reduce :)<br>reduce(lambda a, b: divmod(a[0], b) + a[1:], [(t,), 60, 60, 24])[::-1]<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
P.S. I&#39;m not sure why you had been using floating point<br>
operations.</blockquote></div>no, this wasn&#39;t necessary, I didn&#39;t know about &quot;//&quot;. I could have used int as well...<br><br>Nicholas