Alan> 1. In the time module, the strptime() function's format
    Alan> parameter is optional.  For consistency's sake, I'd expect
    Alan> datetime.strptime()'s format parameter also to be optional.  (On
    Alan> the other hand, the default value for the format is not very
    Alan> useful.)

Correct.  No need to propagate a mistake.

    Alan> 2. Since strftime is supported by datetime.time,
    Alan> datetime.date and datetime.datetime, I'd also expect strptime to
    Alan> be supported by all three classes.  Could you add that now, or
    Alan> would it be better to do it as a separate patch?

That can probably be done, but I'm not convinced strftime really belongs on
either date or time objects given the information those objects are missing:

    >>> t = datetime.datetime.now().time()
    >>> t.strftime("%Y-%m-%d")
    '1900-01-01'
    >>> d = datetime.datetime.now().date()
    >>> d.strftime("%H:%M:%S")
    '00:00:00'

I would be happy for strftime to only be available for datetime objects
(assuming there was a good way to get from time or date objects to datetime
objects short of extracting their individual attributes).  In any case,
going from datetime to date or time objects is trivial:

    >>> dt = datetime.datetime.now()
    >>> dt.time()
    datetime.time(21, 12, 18, 705365)

so parsing a string into a datetime object then splitting out date and time
objects seems reasonable.

Skip
_______________________________________________
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