[Python-3000] More PEP 3101 changes incoming
Adam Olsen
rhamph at gmail.com
Fri Aug 10 19:02:43 CEST 2007
On 8/10/07, Eric Smith <eric+python-dev at trueblade.com> wrote:
> Anyway, if we're keeping conversions, I see two approaches:
>
> 1: "".format() (or Talin's format_field, actually) understands which
> types can be converted to other types, and does the conversions. This
> is how Patrick and I wrote the original PEP 3101 sandbox prototype.
>
> 2: each type's __format__ function understands how to convert to some
> subset of all types (int can convert to float and decimal, for example).
I feel I must be missing something obvious here, but could somebody
explain the problem with __format__ returning NotImplemented to mean
"use a fallback"? It seems like it'd have the advantages of both, ie
repr, str, and several other formats are automatic, while it's still
possible to override any format or create new ones.
--
Adam Olsen, aka Rhamphoryncus
More information about the Python-3000
mailing list