On 9/17/2020 1:28 PM, Ricky Teachey wrote:
On Thu, Sep 17, 2020 at 1:13 PM Eric V. Smith <eric@trueblade.com <mailto:eric@trueblade.com>> wrote:
If someone wanted to play with this in pure Python, string.Formatter's parse() method would do all of the parsing for you.
Surprisingly it is not *quite* all. The format specification mini language parser is not exposed for use. This has bummed me out more than once in the past.
Yeah, I've considered exposing this from the C code, but was never super motivated about it. I go back and forth trying to decide if it's a bad idea or not. If you want to cheat, you can use the version at _pydecimal._parse_format_specifier. The leading underscores should give you an idea of just how unsupported this is! But as far as I know, it works. Eric