[Python-Dev] format, int, and IntEnum

Eli Bendersky eliben at gmail.com
Thu Aug 15 17:49:10 CEST 2013


> This got me thinking when we were discussing it in the issue. It's
> plausible that every subclass of builtin types will need to implement
> __format__ to act sanely. So maybe we can propose some sort of API (on the
> Python level) that makes parsing the format string easy and will not make
> code go stale? What do you think?
>
>
> I've proposed this in the past, primarily for Decimal. I'd be okay with
> it. It would need to done carefully to allow us to expand the format
> string, for example when we added ','. Maybe return a namedtuple or
> equivalent.
>
> But remember, not all types understand the same format strings. datetime
> being the classic case.
>
>
Sure, this is why I specifically restricted it to subclasses of builtin
types, because these should presumably understand the flags used for
builtin types. Anyway, we'll see how much parsing will have to be done in
practice for IntEnum - it can serve as a guinea pig.

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130815/1e799210/attachment.html>


More information about the Python-Dev mailing list