[Python-ideas] strptime without second argument as an inverse to __str__
Steven D'Aprano
steve at pearwood.info
Thu Aug 7 02:32:28 CEST 2014
On Wed, Aug 06, 2014 at 06:48:44AM -0700, Andrew Barnert wrote:
> The purpose of strftime and strptime is to be inverses of each
> other--to generate and parse datetime strings in a specified way. If
> one of those ways is "the default Python string representation" for
> one function, it should be true for the other.
As of Python 3.3, neither strftime nor strptime take a default format.
It's only __str__ which has an implicit default format.
> (Doesn't gnu strf/ptime
> have an extension that gives you % codes for "default" date and time
> representations, which don't guarantee anything other than that they
> be reasonable for the locale and reversible?)
I worry about something like that. Unless the default is guaranteed to
be a particular format, what counts as "reasonable" when the string is
written out and when read back in may not be the same.
--
Steven
More information about the Python-ideas
mailing list