➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author SDesch
Recipients SDesch, eric.smith
Date 2021-11-05.13:31:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
That definition of `.parse()` definitely makes sense. Do you then think this is out of scope for `Formatter` in general or just for `.parse()`?. Just for reference, this is what I currently use to get automatic numbering to work for my use case. 

```
def parse_command_template(format_string):

    auto_numbering_error = ValueError(
        'cannot switch from automatic field numbering to manual field specification')

    index = 0
    auto_numbering = None

    for literal_text, field_name, spec, conversion in Formatter().parse(format_string):
        if field_name is not None:
            if field_name.isdigit():
                if auto_numbering is True:
                    raise auto_numbering_error
                auto_numbering = False

            if field_name == '':
                if auto_numbering is False:
                    raise auto_numbering_error
                auto_numbering = True
                field_name = str(index)
                index += 1

        yield literal_text, field_name, spec, conversion
```
History
Date User Action Args
2021-11-05 13:31:48SDeschsetrecipients: + SDesch, eric.smith
2021-11-05 13:31:48SDeschsetmessageid: <[email protected]>
2021-11-05 13:31:48SDeschlinkissue45704 messages
2021-11-05 13:31:48SDeschcreate