[docs] [issue8913] Document that datetime.__format__ is datetime.strftime

Eric V. Smith report at bugs.python.org
Mon Nov 5 13:37:30 CET 2012

Eric V. Smith added the comment:

To Heikki Partanen excellent point in the review about date __format__ strings allowing you to combine date formatting with other types of formatting:

This is a great point. It's the lack of this that (for example) requires the logging module to have a separate datefmt parameter. With %-formatting, there's no easy way to say:

'{timestamp:%Y%m%d-%H%M%S} {hostname:^40} {count:02d}'.format(timestamp=ts, hostname=host, count=count)

That is, with %-formatting you can't have a single string that specifies both a date/time format and other formatting as well as other formatting specifiers.

I don't think the example in the patch is great, but I do think that it's a good point that needs to be emphasized.


Python tracker <report at bugs.python.org>

More information about the docs mailing list