[docs] Document that datetime.__format__ is datetime.strftime (issue 8913)

ezio.melotti at gmail.com ezio.melotti at gmail.com
Thu Apr 4 03:01:14 CEST 2013


On 2012/11/04 20:02:50, Heikki Partanen wrote:
> http://bugs.python.org/review/8913/diff/6442/Doc/library/datetime.rst
> File Doc/library/datetime.rst (right):
> 
>
http://bugs.python.org/review/8913/diff/6442/Doc/library/datetime.rst#newcode616
> Doc/library/datetime.rst:616: 'John in 2002'
> The idea there is to emphasize the handiness of being able to format a
> date(time) within a single str.format() call. If there are no other
parameters
> in the example, this advantage may go unnoticed. 
> 

Showing that you can pass other parameters is OK, my objection was about
the fact that the resulting sentence seems meaningless to me (not sure
if I'm missing any reference here).

You could just use:
'The {} is {:%Y}'.format("year", d)

or something a bit more complicated like:
>>> 'The {1} is {0:%d}, the {2} is {0:%B}.'.format(d, 'day', 'month')
'The day is 11, the month is March.'



> It was actually suggested earlier by Éric:
> http://bugs.python.org/review/8913/diff/6363/Doc/library/datetime.rst



http://bugs.python.org/review/8913/


More information about the docs mailing list