[Python-Dev] redux: fractional seconds in strptime

Barry Warsaw barry at python.org
Fri Jan 14 12:46:09 CET 2005


On Fri, 2005-01-14 at 06:40, Alex Martelli wrote:

> +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.

None feels better.  I've always thought it was kind of icky for
datetimes to use microseconds=0 to decide whether to print the
fractional second part or not for isoformat(), e.g.:

>>> import datetime
>>> now = datetime.datetime.now()
>>> now.isoformat()
'2005-01-14T06:44:18.013832'
>>> now.replace(microsecond=0).isoformat()
'2005-01-14T06:44:18'

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20050114/b1f9bc15/attachment.pgp


More information about the Python-Dev mailing list