On 2005 Jan 14, at 10:36, Skip Montanaro wrote:


Brett> The problem I have always had with this proposal is that the
Brett> value is worthless, time tuples do not have a slot for fractional
Brett> seconds. Yes, it could possibly be changed to return a float for
Brett> seconds, but that could possibly break things.


Actually, time.strptime() returns a struct_time object. Would it be
possible to extend %S to parse floats then add a microseconds (or whatever)
field to struct_time objects that is available by attribute only? In Py3k
it could worm its way into the tuple representation somehow (either as a new
field or by returning seconds as a float).

+1 -- I never liked the idea that 'time tuples' lost fractions of a second. On platforms where that's sensible and not too hard, time.time() could also -- unobtrusively and backwards compatibly -- set that same attribute. I wonder if, where the attribute's real value is unknown, it should be None (a correct indication of "I dunno") or 0.0 (maybe handier); instinctively, I would prefer None.


"Available by attribute only" is probably sensible, overall, but maybe strftime should make available whatever formatting item[s] strptime may grow to support fractions of a second; and one such item (distinct from %S for guaranteed backwards compatibility) should be "seconds and fraction, with [[presumably, locale-specific]] decimal point inside".


Alex

_______________________________________________
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

Reply via email to