[Python-3000] string.Formatter class
Talin
talin at acm.org
Fri Aug 31 03:31:51 CEST 2007
Eric Smith wrote:
> Ron Adam wrote:
>> I wonder if this is splitting things up a bit too finely? If the format
>> function takes a conversion argument, it makes it possible to do
>> everything by overriding format_field.
>>>> def format_field(self, value, format_spec, conversion):
>> return format(value, format_spec, conversion)
>>>>>> Adding this to Talins suggestion, the signature of format could be...
>>>> format(value, format_spec="", conversion="")
>> But this conflates conversions with formatting, which the PEP takes
> pains not to do. I'd rather leave them separate, but I'll let Talin
> make the call.
Correct. There's no reason for 'format' to handle conversions, when its
trivial for a caller to do it themselves:
format(repr(value), format_spec)
-- Talin
More information about the Python-3000
mailing list