r1chardj0n3s / parse

Parse strings using a specification based on the Python format() syntax.
http://pypi.python.org/pypi/parse
MIT License
1.72k stars 101 forks source link

Format types are not recognized if using field numbering #125

Closed kcbrowning closed 3 years ago

kcbrowning commented 4 years ago

The following results in error parse.parse(:CURR {0:f}, :CURR 5.13) -> Value Error: format spec ':f' not recognised 1.18.0

try:
    tmp = parse.parse(pattern, msg)
except ValueError as exp:
    print(f'parse.parse({pattern}, {msg}) -> Value Error: {exp}')
    print(parse.__version__)

The error will go away if the field numbering is removed ({0:f} to {:f}). Field numbering is commonly used in format. I have not tested it, but I'm guessing this error will with list field numbering as well ({0[0]}).