Skip to content

ValueError: format spec ',d' not recognised #220

@moi90

Description

@moi90

str.format allows to use the comma or the underscore as a digit group separator:

'{:,}'.format(1234567890)
'1,234,567,890'
'{:_}'.format(1234567890)
'1_234_567_890'
'{:_b}'.format(1234567890)
'100_1001_1001_0110_0000_0010_1101_0010'
'{:_x}'.format(1234567890)
'4996_02d2'
'{:_}'.format(123456789.123456789)
'123_456_789.12345679'
'{:.,}'.format(123456789.123456789)
'123456789.123,456,79'
'{:,._}'.format(123456789.123456789)
'123,456,789.123_456_79'

However, when using a format string like "{:,d}" in parse, I get the following error: ValueError: format spec ',d' not recognised.

I guess extract_format needs to be told about this, and then Parser._handle_field.

I did some experimentation, but this is not yet done:

master...moi90:int-seperator

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions