On Wed, Apr 23, 2008 at 10:35 PM, Alex Martelli <[EMAIL PROTECTED]> wrote:
> Is 119 vs 117 characters "a LOT of verbosity"...?! OK, then what about...: the reduce is actually 69 *and only one line* if you don't need it in a function. You can't put the dhms2 in a function unless you want to leak a bunch of variables like 'd', 'r', and 't'... reduce(lambda a, b: a[:-1] + [a[-1]%b, a[-1]//b], [[t], 60, 60, 24]) On Wed, Apr 23, 2008 at 10:40 PM, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > py> time % 60, time//60%60, time//3600%24, time//(3600*24) > (28, 7, 0, 22) 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 :) reduce(lambda a, b: divmod(a[0], b) + a[1:], [(t,), 60, 60, 24])[::-1] P.S. I'm not sure why you had been using floating point > operations. no, this wasn't necessary, I didn't know about "//". I could have used int as well... Nicholas
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com