Dnia 24-04-2008, czw o godzinie 07:40 +0200, "Martin v. Löwis" pisze:
> In this case, I wouldn't use a loop at all:
>
> py> time=1901248
> py> minutes,seconds = divmod(time, 60)
> py> hours,minutes = divmod(minutes, 60)
> py> days,hours = divmod(hours,24)
> py> seconds,minutes,hours,days
> (28, 7, 0, 22)
divmod could be extended to more arguments:
days, hours, minutes, seconds = divmod(time, 24, 60, 60)
def divmod(x, d, *ds):
if ds:
q, *rs = divmod(x, *ds)
q1, r1 = divmod2(q, d)
return q1, r1, *rs
else:
return divmod2(x, d)
--
__("< Marcin Kowalczyk
\__/ [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com