original) (raw)
(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.�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?
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.
�