Message195311
On 8/16/2013 12:24 AM, Ethan Furman wrote:
>
> Ethan Furman added the comment:
>
>> Eric V. Smith added the comment:
>>
>> But a datetime format string can end in "0", for example.
>>
>>>>> format(datetime.datetime.now(), '%H:%M:%S.00')
>> '20:25:27.00'
>
> Not a problem, because once the digits were removed there would still be % : H M S and ., so the datetime format would
> be called. str format would only be called when the result of removing < ^ > 0 1 2 3 4 5 6 7 8 9 was an empty string.
Ah, I misread your earlier text. You'd want to remove 's' also, wouldn't
you?
You might be able to guess whether this particular format spec is a str
format spec or not, but it can't work in the general case, because not
all types with format specifiers have been written yet. I can imagine a
type with a format specification that's identical to str's (yet produces
different output), and you'd always want to use its __format__ instead
of str.__format__.
I feel strongly this is sufficiently magic that we shouldn't do it, and
instead just implement the more robust algorithm in IntEnum.__format__.
But I'm not going to argue it any more. |
|
Date |
User |
Action |
Args |
2013-08-16 04:31:32 | eric.smith | set | recipients:
+ eric.smith, barry, eli.bendersky, ethan.furman, serhiy.storchaka |
2013-08-16 04:31:32 | eric.smith | link | issue18738 messages |
2013-08-16 04:31:31 | eric.smith | create | |
|