On Fri, 2005-06-17 at 05:57, Raymond Hettinger wrote: > This PEP has been open for two and half years without generating > discussion or support.
Interesting. Just yesterday I wrote a simple stopwatch-like timer script and I found that I needed three divmod calls to convert from seconds into a datetime.time object. This PEP might have come in handy there, but OTOH, I'm not so sure that's enough justification to accept the PEP. > Its primary case (converting cumulative seconds into a tuple days, > hours, minutes, and seconds) is a bit wanting because it doesn't > generalize to months and years. That need is already met in a more > robust and flexible way by date and time specific modules. Actually, no, because datetime.time(seconds=50227) throws an exception. But in my specific case, I didn't find the need for three divmod calls nearly as frustrating as the lack of a datetime.time.fromseconds() call. > More importantly, the gain in succinctness is offset by a loss of > clarity. Consider: > > dist, inches = divmod(dist, 12) > yards, feet = divmod(dist, 3) > > versus a proposed: > > yards, feet, inches = divmod(dist, 3, 12) > > The latter form makes it difficult to visually confirm the correct > number of target variables. Likewise, it is not at all obvious that the > order of the 3 and 12 are correct. I agree. My three divmod solution is perfectly readable and simple to write. -Barry
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com